Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tool for importing CSV files into MySQL database? [closed]

I've got several CSV files I want to import into a table. They all contain different numbers of columns, so some data will be absent during each import. I need a tool that will let me map which CSV column goes into which MySQL column. Doesn't look like MySQL workbench can do this. What else can I use?

like image 425
mpen Avatar asked Sep 17 '25 04:09

mpen


2 Answers

MySQL has the LOAD DATA INFILE syntax:

LOAD DATA INFILE 'data.txt' INTO TABLE tbl_name
 FIELDS TERMINATED BY ',' ENCLOSED BY '"'
 LINES TERMINATED BY '\r\n'
 IGNORE 1 LINES;

See the documentation about custom data handling.

like image 66
OMG Ponies Avatar answered Sep 19 '25 20:09

OMG Ponies


If you're running on a Mac, Sequel Pro is pretty good for this sort of thing (as long as you import each CSV file individually).

http://www.sequelpro.com/

like image 40
jranz Avatar answered Sep 19 '25 18:09

jranz