1

I'm trying to import a CSV into MySQL via Phpmyadmin. My file is exported from another software i can't access or control. Sadly, the file "export.csv" contains in line one some "info about the other db" and in line 2 it contains the column names.

Im using the following settings:

file: import.csv
character Set of file: iso-8859-1
Skip this number of queries (for SQL) or lines (for other formats), starting from the first one : 2
format: CSV
columns separated by: ;

but i always get the error "column count not matching in line: 1".

if i delete the two first lines in the csv file, it works perfect.

it looks to me like the skip rows does not work. But why?

sgt_johnny
  • 329
  • 2
  • 16
  • can you get to a sql query window and execute commands ? – Drew Dec 01 '15 at 08:52
  • yes i could, what should i execute? – sgt_johnny Dec 01 '15 at 08:57
  • [LOAD DATA INFILE](http://dev.mysql.com/doc/refman/5.7/en/load-data.html) like [this one](http://stackoverflow.com/a/32558176/) but tweaking with [IGNORE number {LINES | ROWS}] – Drew Dec 01 '15 at 09:01
  • do the column names in the CSV match up to the column names in the DB? If not, you may need to fill the `Column names` field (which only shows up when doing an import into a specific table). – br3nt Dec 01 '15 at 09:30
  • i wanna skip the column names... – sgt_johnny Dec 01 '15 at 10:22

1 Answers1

0

You must first select the table into which you want to import the CSV file. You do this by clicking on the table name. Then you can click on the Import Tab. If you use the wrong order in this place, then you will be lead to the only SQL import feature. This will still be the Import Tab, however the CSV import feature will not show up. So make sure that you see this menu Format of imported file with the option CSV directly below. Otherwise you must retry to get to this place.

Number of records(queries) to skip from start: 1

Format of imported file
CSV

CSV using LOAD DATA

SQL

Then you choose CSV and the correct options on the right side:

Fields terminated by ;
Fields enclosed by "
Fields escaped by \
Lines terminated by auto
Column names ...

You must copy the first line of your CSV file and remove the "" and replace the ; by , in order to have the column names. You must insert these column names also here in this form after "Column names" instead of my three dots (...) .

E.g.:

Column names uid,pid,tstamp,crdate,deleted,hidden,starttime,endtime,fe_group,title,subtitle,itemnumber,price,note,image,inStock

The result will be shown like this:

Import has been successfully finished, 94 queries executed.
Franz Holzinger
  • 913
  • 10
  • 20