4

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?

mpen
  • 272,448
  • 266
  • 850
  • 1,236
  • I would start by adjusting the data with a spread sheet like excel in order to remove the column issues. – madmik3 Jan 27 '11 at 05:35

2 Answers2

7

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.

OMG Ponies
  • 325,700
  • 82
  • 523
  • 502
4

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/

SchmitzIT
  • 9,227
  • 9
  • 65
  • 92
jranz
  • 41
  • 1