Hi! Thanks for visiting my blog. If you've received any value from my content would you mind supporting my new startup by downloading our browser add-on? It's called PriceBlink and makes online shopping a breeze. You can watch it in action here and download it for Chrome, Firefox, IE, or Safari by going to PriceBlink.com. Thank you and I hope you enjoy!

Using mysqlimport with CSV Files

Jan 28

It’s been a good while since I’ve imported data into mysql using the command line.  In the past I’ve used the load data infile syntax, but this time decided to use the mysqlimport client instead.  The raw data from the csv file looked like the following:

“Microsoft”, “MSFT”
“Macromedia”, “MACR”
“Google”, “GOOG”

and to actually parse this data and load it into mysql I used the following command:

mysqlimport –fields-enclosed-by=’”‘ –fields-terminated-by=’,’ –lines-terminated-by=”\n” –columns=name,symbol –user=root stocks nasdaq.csv

Also note that the name of the database was stocks and table was nasdaq.  The mysqlimport client automatically looks for a table name that matches the name of the file….before the extension.

Leave a Reply