Jump to content

Ignore comma in csv file before importing into database?


candice

Recommended Posts

Hi all, I have a csv file that i need to import into my sql database. The csv file itself contains extra commas, that is screwing the whole app up since mysql reads the comma as a field separator. I have tried using a different field separator and also other methods such as implode/explode/str_replace etc, but it doesnt seem to work. Can anybody help me? Thanks!!

Firstly, why are there extra commas in it in the first place? Is it the case that the fields contain strings with commas in them, e.g. "this is , my sentence"?

 

If that's the case then you need to alter the export to enclose the fields in inverted commas ("), then you can specify the field encapsulator in the import. This will resolve your problem...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.