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:
- The condition is that the table “transaction_upload” should be already exist.
- It upload first row of csv too which contain header.
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 LINESto the end of yourLOAD DATAcommand.As the manual says:
If the table does not already exist, MySQL will raise an error.