MySQL Forums
Forum List  »  Knowledge Base

Re: Import multiple CSV files in one Mysql table.
Posted by: Paul Svirin
Date: September 13, 2009 09:54AM

1. I think the bast way is to split the CSV accroding to your needs befor importing into different files named according to the tables to be imported, e.g.:

head -n -10 a.csv > A.csv
tail -n +10 | head -n 20 > B.csv

etc.

then use the mysqlimport statement like the one below with multiple input files:

mysqlimport ... A.csv B.csv ...


2. Try this:

mysqlimport --fields-optionally-enclosed-by="\"" --fields-terminated-by=, --lines-terminated-by="\n" --user=<username> --password <db_name> --local --ignore-lines=1 ./<table_name>.csv

Input file format:

"id","name"
"1","name1"
"2","name2"

where line 1 is fields caption.

---------------
StarWind Software developer ( http://www.starwindsoftware.com )

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: Import multiple CSV files in one Mysql table.
7216
September 13, 2009 09:54AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.