Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mysql LOAD DATA INFILE not working

Tags:

mysql

csv

I am trying to use mysql LOAD DATA INFILE on command line to load csv file. It neither gives any error nor it loads any data. Can anyone please help me out? I am using following command

mysql> LOAD DATA INFILE '/Applications/XAMPP/xamppfiles/htdocs/dev/__php__/mysql/data.csv'
->             INTO TABLE csvdata
->               FIELDS TERMINATED BY ','
->               OPTIONALLY ENCLOSED BY '"'
->               LINES TERMINATED BY '\n'
->               IGNORE 1 LINES;
Query OK, 0 rows affected (0.00 sec)
Records: 0  Deleted: 0  Skipped: 0  Warnings: 0

Following is my CSV file

"emp_id","first_name","last_name","username"
"EMP1","Tibass","Deloris","Tibass1"

Regards

like image 858
amique Avatar asked Feb 14 '23 19:02

amique


1 Answers

Probably your file line terminator differs from your definition in the LOAD DATA statement.

Try the \r\n or \r instead of the \n.

like image 108
Cristian Porta Avatar answered Feb 17 '23 11:02

Cristian Porta