Twitch
Twitch

Reputation: 693

How to import CSV into MySQL with fields separated by commas and also contain commas but no enclosers

I have a CSV file but the strings within the fields contain commas. There are no enclosures within the fields to distinguish the fields from the commas.

i.e.: Sat Apr 20 14:50:47 CDT 2013,twitter_handle,News 'SURPRISE': Blah blah 'Stuff,' People Say http://link.to/something,,

I've been reading through LOAD DATA INFILE but I'm not seeing anything to help with this.

Upvotes: 0

Views: 819

Answers (1)

Eric J.
Eric J.

Reputation: 150198

If data fields that contain a comma are not properly quoted, there is no way that any computer program can decide which commas are intended as field separators and which are part of the data itself.

Speak to the source of your CSV file and ask them to either use proper quoting, or use a separator that will not appear in a data field (e.g. tab separator).

Upvotes: 2

Related Questions