I want to do something really simple.
I just want to export excel data to a CSV in order to put it in a Mysql DB.
It is a huge excel so I can’t manage exceptions easily.
My problem is that when I save my xslx into csv, it put me the " to separate columns only if there is a comma in the column or if there is already a " so I have something like that in my CSV :
col1 | col2 | col3 => col1,col2,col3
col1 | co,l2| col3 => col1,"co,l2",col3
col1 |"col"2| col3 => col1,"""col""2",col3
col1 | | col3 => col1,,col3
So I tried a lot of tings to convert it for SQL but i don’t find a good way.
I work in Excel 2007 and SQL want to CSV to have this config:
Columns separated with: ,
Columns enclosed with: "
Columns escaped with: \
Lines terminated with: auto
So you want to load your data using
The
OPTIONALLYis actually ignored when loading a file, or to phrase it a better way, even if you don’t specifyOPTIONALLY, the enclosing will still be treated as optional. Which means that a column value may be enclosed in quotation marks, but need not be. Note that afaik. Excel does not use\to escape values.If you need some other format for purposes other than importing into MySQL, then you may re-export the data from MySQL afterwards, with the settings you prefer. When writing a file, omitting the
OPTIONALLYwill turn quotes on for every value.