tags:

views:

47

answers:

1

Hi all,

Im working on a large project, havent had to do what I need help with before. I have a csv file, it contains a large amount of data, namely all of the cities, towns, suburbs in Australia. I need to convert the csv file to sql for mysql, and then import it into the database.

What would be the best way to achieve this?

Thanks all, Lea

+1  A: 

Use LOAD DATA INFILE or the equivalent command-line tool mysqlimport.

These are easy to use for loading CSV data, and this method runs 20x faster than importing rows one at a time with SQL.

Bill Karwin
Thanks. I did try to use the LOAD DATA INFILE method, but it would not accept my path to the csv file. Any suggestions?
Lea
@Lea - This is the way to go. What is the problem with the path ? +1
Romain Hippeau
@Romain Hippeau it simply returns the error "csv file not found". I tried to use the absolute path to the file, but it doesnt seem to accept it.
Lea
@Lea can you run it from the location where your csv file is located ?
Romain Hippeau
Try `LOAD DATA LOCAL INFILE` otherwise it wants the file to be under the MySQL Server's data directory.
Bill Karwin
@Lea - Did you try Bill's idea above ?
Romain Hippeau