MySQL import in phpmyadmin (CSV) chokes on quotes

Posted by Andrew Swift on Stack Overflow See other posts from Stack Overflow or by Andrew Swift
Published on 2009-06-26T09:19:33Z Indexed on 2010/05/14 10:44 UTC
Read the original article Hit count: 248

Filed under:
|
|
|
|

I am trying to import a .csv file into a MySQL table via phpMyAdmin.

The .csv file is separated by pipes, formated like this:

data|d'ata|d'a"ta|dat"a|
data|"da"ta|data|da't'a|
dat'a|data|da"ta"|da'ta|

The data contains quotes. I have no control over the format in which I recieve the data -- it is generated by a third party.

The problem comes when there is a | followed by a double quote. I always get an "invalid field count in CSV input on line N" error.

I am uploading the file from the import page, using Latin1, CSV, terminated by |, separated by ".

I would like to just change the "enclosed by" character, but I keep getting "Invalid parameter for CSV import: Fields enclosed by". I have tried various characters with no success.

How can I tell MySQL to accept this format in phpMyAdmin?

Setting up these tables is the first step in writing a program that will use uploaded gzipped .csv files to maintain the catalog of an e-commerce site.

© Stack Overflow or respective owner

Related posts about php

Related posts about phpmyadmin