MySQL Forums
Forum List  »  PHP

Re: Importing part of a .csv file
Posted by: Barry Galbraith
Date: November 14, 2012 02:47PM

Int the refman for LOAD DATA INFILE, about half way down theres a description of how to load some fileds, skip others, and discard some input.

Quote
refman says
You can also discard an input value by assigning it to a user variable and not assigning the variable to a table column:

LOAD DATA INFILE 'file.txt'
INTO TABLE t1
(column1, @dummy, column2, @dummy, column3);

So, you probably need something like this.

LOAD DATA INFILE 'my.csv'
INTO my_table
(Title_1, Title_2, Title_3, Title_4, @dummy5, @dummy6, @dummy7)

You'll need to add the FIELDS TERMINATED BY and LINES TERMINATED BY clauses to suit your file.

BTW, a row is one horizontal line in your table. The verticals are fields or columns.

Good luck,
Barry.

Options: ReplyQuote


Subject
Written By
Posted
Re: Importing part of a .csv file
November 14, 2012 02:47PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.