Search code examples
mysqlcsvload-data-infile

MySQL ERROR CODE 1265: what's wrong with my csv data?


A TABLE shiyanyong was created. After that, I got Error Code: 1265.Data trancated forcolumn'income' at row 1 when i'm trying to load csv file data into shiyanyong.

Is there something wrong with the csv data? or some other issues with the SQL CODE?

At the same time, it works with

INSERT INTO shiyanyong VALUES('AA', 0.22);

1) TABLE

CREATE TABLE shiyanyong(
company_name VARCHAR(40),
income DOUBLE
);

2) LOAD DATA:

LOAD DATA INFILE 'D:\2018.csv'
INTO TABLE shiyanyong
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\n'
IGNORE 1 LINES;

3) The DATA of 2018.csv for exaple like this:

company_name    income
A                  0.60
B                  1.80
C                  8.00

Solution

  • It works when i replaced LINES TERMINATED BY '\n' by LINES TERMINATED BY '\r\n'.