Skip to content

Instantly share code, notes, and snippets.

@nanusdad
Last active November 28, 2015 07:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nanusdad/e9b1e3f5b6c9285d8363 to your computer and use it in GitHub Desktop.
Save nanusdad/e9b1e3f5b6c9285d8363 to your computer and use it in GitHub Desktop.
Excel to CSV to MySQL
  1. Save Excel worksheet as .csv file
  • might need to change new line characters
  • if saving on Mac - open in vi and run %s/^M/\r/g ( ctrl+M )
  1. Use the following example to load in CSV file from mysql prompt -
    load data infile '/tmp/tc_t.csv' 
    into table new_test_categories 
    fields terminated by ','    
    enclosed by '"' 
    lines terminated by '\n' 
    ignore 1 lines 
    (id,category_name,type_id,home_collection,seo_tags,status_id);

Read more at - https://dev.mysql.com/doc/refman/5.1/en/load-data.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment