Reputation: 1296
this may just be the dumbest question I have asked yet. But I can not figure this out. I am trying to import a CSV into my mysql. But I can not get these areas correct:
Columns separated with: Columns enclosed with: Columns escaped with: Lines terminated with:
Here is an example row in mycsv: AA|Armed Forces Americas|US|United States
what would I place in each one?
Upvotes: 1
Views: 228
Reputation: 3038
If you have table that match the column configuration of the file what you do is:
LOAD DATA INFILE '<full file path>`
INTO TABLE <tbl_name>
FIELDS TERMINATED BY '|' LINES TERMINATED BY '\n';
If some of the fields may contain |
then these fields should be enclosed by "
and then the last clause becomes:
FIELDS TERMINATED BY '|' ENCLOSED BY '"' TERMINATED BY '\n'
Upvotes: 1