2009-03-06

Problem with phpMyAdmin Table CSV Data Import

There is a problem with the table data import functionality in phpMyAdmin.

Actually, there are a couple problems -

  • The default value for the field separator character is a semi-colon (';') - WtF? CSV stands for "Comma Separated Value" - how are the designers going to use a semicolon to separate the field values in a format named to have comma characters as field value separators?
  • The CSV format exported by Excel, and (it seems) OpenOffice Calc, is implemented such that double quote characters within a field are escaped in the CSV output by use of two double quote characters used sequentially (I.E. like "this is a CSV field with an escaped double quote character ("") embedded"). This causes the phpMyAdmin table data import to fail. [see below for more detail]

CSV Format Issues

Apparently phpMyAdmin wants the *nixish escape (I.E. \") instead of the "" style used by popular spreadsheet software.

Possible Solutions

  • Modify the data within the CSV file to conform to phpMyAdmin expectations - this is generally unacceptable, since the data shouldn't be touched
  • Modify the phpMyAdmin import function to correctly handle Excel's output

CVS Format References