Reputation: 99
I'm trying to import a 300 000 line CSV file to MySQL with phpMyAdmin 2.8.0.1. File size is 8 MB after gzipping.
I manage to import about 800 - 2000 lines and after that phpmyadmin throws an "invalid field count in csv" error.
If I delete these lines from the beginning of csv and try import, phpmyadmin manages to import that same line which an error was thrown before.
Maybe this is related to php settings? Which values should i change?
Upvotes: 2
Views: 2874
Reputation: 12412
First thing I'd suggest trying is uploading the uncompressed CSV file and see how that goes. You may indeed be hitting a PHP resource limit and not needing to uncompress the file first might help.
Upvotes: 0
Reputation: 8809
it may possible that your php.ini have default settings like this
post_max_size = 8M
upload_max_filesize = 2M
change them to
post_max_size = 20M
upload_max_filesize = 20M
and restart your services.
Upvotes: 1
Reputation: 575
Use the LOAD INFILE function instead of phpMyAdmin - it manages also bigger CSV files. (Have made it with about 350.000 lines without problems.)
PHP Example:
$sql = "LOAD DATA LOCAL
INFILE 'test.csv'
INTO TABLE my_table
FIELDS
TERMINATED BY ','
OPTIONALLY ENCLOSED BY '\"';";
$insert = mysql_query($sql);
Upvotes: 1