简体   繁体   中英

Import Big csv file into mySql

I am trying to import 300 mg csv file into mySql table. I am using this command:

LOAD DATA INFILE 'c:/csv/bigCSV.csv' IGNORE 
INTO TABLE table
FIELDS TERMINATED BY ',' 
LINES TERMINATED BY '\r\n'
IGNORE 1 LINES

And it works great with small files (1 mg and so on), but when I try to load a big file like the one mentioned, MySql Workbench (which I use to execute my queries) runs the command, everything ok and green but 0 rows affected. No changes at all in the table.

I am 10000% sure that the table is ok because when I take a portion of that file, eg 1mg and load it into the same table it works fine.

Did anyone had this kind of problems?

Thank you.

I have "solved" it. Don`t know why and I feel stupid for not playing with the statement earlier but like this:

LOAD DATA INFILE 'c:/csv/eventsbig.csv' IGNORE 
INTO TABLE std9
FIELDS TERMINATED BY ',' 
LINES TERMINATED BY '\n'

Without the "IGNORE 1 LINES" at the end and it works with files of any size.

LOAD DATA LOW_PRIORITY LOCAL INFILE 'C:\\Learning\\App6_DBconnection\\CC.csv' 
INTO TABLE `test`.`ccd` 
CHARACTER SET armscii8 
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' ESCAPED BY '"' LINES TERMINATED BY '\r\n' 
IGNORE 1 LINES (`Cd_Type`, `Full_Name`, `Billing_Date`);

This will work even for large data sets of more than 15 lakh records.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM