in reply to loading csv files into MySQL databse

Read http://dev.mysql.com/doc/refman/5.0/en/load-data.html for how to load data using MySQL's own data loading command. That will tell you how to properly quote, escape, and manage all your data issues.

My criteria for good software:
  1. Does it work?
  2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?
  • Comment on Re: loading csv files into MySQL databse

Replies are listed 'Best First'.
Re^2: loading csv files into MySQL databse
by EvanCarroll (Chaplain) on May 16, 2008 at 19:54 UTC
    I second this. LOAD DATA is really the best way to do this if it will work with your data format. It is more flexible than PG's COPY too (see REPLACE and IGNORE). If it doesn't work take a look at Text::CSV which is probably the best CSV library ever.


    Evan Carroll
    I hack for the ladies.
    www.EvanCarroll.com

      Get a mysql shell prompt and issue a command like:

      mysql> LOAD DATA INFILE '/path/to/mtp4date.csv' REPLACE INTO TABLE vot +ers FIELDS TERMINATED BY ','