Hi I am trying to be at point.
I am trying to upload CSV into mysql atonce by using php in windows. so I am using the query
LOAD DATA INFILE 'c:/Data/mysql/transaction_upload.csv'
INTO TABLE transaction_upload
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
ESCAPED BY '\\'
LINES TERMINATED BY '\r\n';
it load my whole csv into the table.
The problem is:
I want that first row will removed from CSV i.e. the header should not be have entry in DB and the table created automatically having name as CSV_file_name and columns as CSV first row's columns.
Please do not answer as read first line of CSV in php and create table because the problem of removing first row from is still there.
Add IGNORE 1 LINES
to the end of your LOAD DATA
command.
As the manual says:
The
IGNORE
number
LINES
option can be used to ignore lines at the start of the file. For example, you can useIGNORE 1 LINES
to skip over an initial header line containing column names:LOAD DATA INFILE '/tmp/test.txt' INTO TABLE test IGNORE 1 LINES;
If the table does not already exist, MySQL will raise an error.