Here are the steps for exporting MS Win/Excel data into a MySQL database hosted on Mac OS 10.5
- Save the Excel data as a tab delimited file, and move the file to the Mac OS (for some reason I've found more consitant success starting from a tab delimited file than with a .csv.
- Open the Excel tab delimited file in Numbers spreadsheet program and export as CSV. Doing this seems to work out any WIN/Mac file formatting errors.
- Run the following command at the terminal in the Mac OS
load data local infile
-> '~/filename.csv' into table tablename
-> fields terminated by ','
-> lines terminated by '\n'
-> (field_1, field_2, field_n); - The statement above assumes your data is separated by comas, and lines are terminated by the newline character; field_1, field_2, field_n are positional -- that is, whatever column comes first in filename.csv will be mapped to the field_1, whatever comes second in filename.csv will be mapped to field_2 etc...
Never look this up again.
No comments:
Post a Comment