Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

How to skip csv header while sqoop export into mySql table.

Highlighted

How to skip csv header while sqoop export into mySql table.

New Contributor

mySql table structure is:

CREATE TABLE Demo_Sales ( id INT NOT NULL PRIMARY KEY, product_name VARCHAR(30), brand VARCHAR(20), cust_email VARCHAR(50), quantity INT);

and the csv file has a header:

id,product_name,brand,cust_email,quantity

Because id is INT, so the sqoop command fails. Is there a way to skip the header line in the csv file while using sqoop export into the mySQL table. Thanks

3 REPLIES 3

Re: How to skip csv header while sqoop export into mySql table.

Why not skip the header line when you load the CSV into MySQL? Using IGNORE n LINES (n is lines to skip so for you it should be 1). Then sqoop export to Hive, HDFS,etc.

Re: How to skip csv header while sqoop export into mySql table.

New Contributor

My csv file is present in HDFS, need to export that file to load data in mySql table. The csv file has header row, because of which int primary key constraint is violated. Need to know, if we can ignore lines while doing a sqoop export or the only option is to edit the csv and remove the header row from top. Thanks

Re: How to skip csv header while sqoop export into mySql table.

@Kushal Khera

Sqoop does not have an option to remove headers. Try using --update-key and --update-mode with updateonly and see if it helps.