I’m trying to import a CSV file into phpMyAdmin, and I don’t understand the error “Data truncated for column 1.” Since the field id is to be auto-incremented, I left it out at first, but I got an error concerning the field count. I then tried putting just a semicolon in front of everything, thinking that MySql would see a NULL value and auto-increment all the rows. Not so. Instead I got an error that the ‘id’ isn’t an integer, so I assigned ids for all the rows. I also made sure that the character encoding was consistent – utf8.
Here’s the structure of the table:
Field Type Collation Atributes Null Default Extra
id int(6) Não None AUTO_INCREMENT
data date Não None
apto int(3) UNSIGNED Sim NULL
descricao varchar(100) utf8_general_ci Não None
rec float(11,2) Sim NULL
pag float(11,2) Sim NULL
Here´s the first row that gave the error (the name has been changed to protect the innocent):
1;2012-01-03;101;Fred - janeiro;90.00;
I have a semicolon at the end because the last field has a value of NULL
I know it’s not the most elegant solution, but just say no to CSV with phpMyAdmin. Using macros and regular expressions in my favorite text editor (TextPad), I converted my CSV file into an SQL file, and imported it without any problem.