MySql import CSV space problem
I have a data file which looks like that:
001,000,D,Bla bla bla
I import it into a mysql database with following code:
LOAD DATA LOCAL
INFILE 'D开发者_如何学Go:\test.dat'
INTO TABLE typen
FIELDS TERMINATED BY ','
IGNORE 1 LINES;
I get warnings for every line:
Warning | 1265 | Data truncated for column 'typ1' at row 1
and when I look at the content of the table there is a space between every character. It looks like that:
0 0 1 | 0 0 0 | D | B l a b l a b l a
Am I missing something?
The problem is the encoding of the file. I did not find the correct encoding for this file so I opened it in Notepad++ changed the encoding to utf8 and used follwing code:
LOAD DATA LOCAL
INFILE 'D:\test.dat'
INTO TABLE typen
CHARACTER SET 'utf8'
FIELDS TERMINATED BY ','
IGNORE 1 LINES;
精彩评论