phpMyAdmin - manually import csv and skip columns

时间:2017-06-15 09:52:23

标签: mysql csv import phpmyadmin

In phpMyAdmin, in the tab import, how to specify which columns of the csv must be skipped by the import?

For example, I have this csv:

col1    col2    col3    col4    col5
a       b       c       x       0
1       2       3       y       1

I need to manually import that csv skipping the 4th column.

With the Csv using LOAD DATA I can specify the Column names; in that field I tried to insert these but without working:

col1, col2, col3, @dummy, col5

Invalid column (@dummy) specified! Ensure that columns names are spelled correctly, separated by commas, and not enclosed in quotes.

and

col1, col2, col3, , col5

SQL query:

LOAD DATA LOCAL INFILE '/tmp/phpBlaBlaBla' INTO TABLE `tblName` FIELDS TERMINATED BY ';' ENCLOSED BY '"' ESCAPED BY '\' LINES TERMINATED BY '\n' IGNORE 1 LINES (`col1` , `col2` , `col3` , , `col5`)

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near `col5`)' at line 1

The phpMyAdmin version is 4.0.10.16.

Thanks a lot

0 个答案:

没有答案