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.
