How to import CSV into mysql if values contains comma -


i've csv file values may have comma part of value

"09200, france, paris", "tower ""olivia""" "09200, spain, barselona", shop - perfect 

however once import data breaks value on 4 columns (based on number of comma in row). do wrong? please see import command below.

load data local infile '~/downloads/file.csv' table my_table character set utf8 fields terminated ',' lines terminated '\n' (@col1,@col2) set address=@col1,name=@col2; 

add enclosed by clause query:

load data local infile '~/downloads/file.csv'    table my_table    character set utf8    fields terminated ','    optionally enclosed '"'   lines terminated '\n'   (@col1,@col2) set address=@col1,name=@col2; 

Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -