Reputation: 31
I can import CSV file with CSV option but doesnt work for CSV with LOAD DATA. I get the error
Error: 1083 - Field separator argument is not what is expected
...although I am doing everything same,uploading the same file to same table.
Upvotes: 3
Views: 1636
Reputation: 12123
You are probably forgetting to set the field separator to a comma. Here's an example command for loading a CSV file from the MySQL documentation.
LOAD DATA INFILE can be used to read files obtained from external sources. For example, many programs can export data in comma-separated values (CSV) format, such that lines have fields separated by commas and enclosed within double quotation marks, with an initial line of column names. If the lines in such a file are terminated by carriage return/newline pairs, the statement shown here illustrates the field- and line-handling options you would use to load the file:
LOAD DATA INFILE 'data.txt' INTO TABLE tbl_name
FIELDS TERMINATED BY ',' ENCLOSED BY '"'
LINES TERMINATED BY '\r\n'
IGNORE 1 LINES;
Some notes:
IGNORE 1 LINES
. LOAD DATA LOCAL INFILE
.Upvotes: 2