Skip to content

Instantly share code, notes, and snippets.

@matthewpoer
Created August 11, 2014 15:18
Show Gist options
  • Save matthewpoer/c7a665ad2aea52b5bbd3 to your computer and use it in GitHub Desktop.
Save matthewpoer/c7a665ad2aea52b5bbd3 to your computer and use it in GitHub Desktop.
Import from CSV to MySQL table using "load data local" and the CSV has damn newlines in the data. Make sure all fields are enclosed correctly in quotes.
load data local infile '/Users/MKP01/Documents/Studio Center/Matt Import/notes_csv_fixed_quote/note.csv'
into table notes
fields terminated by ','
enclosed by '"'
-- lines terminated by '\n'
ignore 1 lines
(contact_id,@date_entered,@created_by,@date_modified,modified_user_id,description,@bad_id,name)
set id = UUID(),
date_entered = STR_TO_DATE(@date_entered,'%m/%e/%Y %H:%i'),
date_modified = STR_TO_DATE(@date_modified,'%m/%e/%Y %H:%i'),
created_by = @created_by,
assigned_user_id = @created_by;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment