0

I have the following CSV File:

AFRICA,Zimbabwe,7,Telecel Zimbabwe,1,0,1,0,0,1
AFRICA,Zambia,7,Celtel Zambia Plc,1,0,1,0,0,1

I am using the following query but for some reason it's giving an error:

LOAD DATA LOCAL INFILE 'pathtofile' INTO TABLE databasename.tablename FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n';

It is giving a data truncated warning and not importing anything

user3492795
  • 193
  • 5
  • 19
  • possible duplicate of [How to create and populate a table in a single step as part of a CSV import operation?](http://stackoverflow.com/questions/10418461/how-to-create-and-populate-a-table-in-a-single-step-as-part-of-a-csv-import-oper) – Shishdem Apr 14 '14 at 11:08
  • 1
    You give `ENCLOSED BY '"'` but I see no single `"` – fancyPants Apr 14 '14 at 11:09
  • If only some of the CSV file uses `"`, then change `ENCLOSED BY` to `OPTIONALLY ENCLOSED BY` – jon Apr 14 '14 at 11:22

2 Answers2

0

First of all you need to ensure that the receiving data fields are in the correct order and are of the correct type and size.

Then you specify ENCLOSED BY '"', but your example data is not actually enclosed...

LSerni
  • 55,617
  • 10
  • 65
  • 107
0

Check The Query in database :

LOAD DATA LOCAL INFILE 'abc.csv' INTO TABLE abc
FIELDS TERMINATED BY ',' 
ENCLOSED BY '"' 
LINES TERMINATED BY '\r\n'
IGNORE 1 LINES
(col1, col2, col3, col4, col5...) 
Sathish D
  • 4,854
  • 31
  • 44