Reputation: 95
MAC OSX MAVRICKS
Hello I have a very CSV file that I am attempting to use LOAD INFILE with mysql
Here is what the CSV looks like....
f1,f2
a,e
b,f
c,g
d,h
Here is my CREATE TABLE statement:
create table test_import_csv (
f1 VARCHAR(20),
f2 VARCHAR(20)
);
Here is my LOAD INFILE statement;
load data local infile '/Users/name/Downloads/test_import_csv.csv'
into table test_import_csv
fields terminated by ','
LINES TERMINATED BY '/n'
(f1, f2);
this statement goes through however this is what it looks like...
mysql> select * from test_import_csv;
+------+------+
| f1 | f2 |
+------+------+
a |1 | f2
+------+------+
1 row in set (0.00 sec)
I have tried variations in the loadinfile statement as well as giving it an primary KEY ID... but nothing works...
Anyone know what is going on and why loadinfile is not working for this simple CSV?
Upvotes: 0
Views: 1006
Reputation: 1140
If your query can import one row, I suspect the problem is with your line termination. If your csv is created in Windows it may be using '\r\n' as line terminator. Try LINES TERMINATED BY '\r\n'
Upvotes: 2