Import csv file to MySQL with two different fields terminate
Posted: Wed Oct 10, 2012 8:26 am
Hello,
How to import csv file with two different field terminated. I use this code
to import file, but somewhere I have it ";" . How to import this different field.
This is my row from csv file.
[text]
401,1,colomn4,500053;example1;0000000585;21.07.2011,,,,"0,000","0,000","0,000","00,000,000","0,000","0,000","0,000",0,"0,000","0,000","0,000","0,908","0,000","0,000","0,000",0,"0,000","0,000","0,000",0,"0,000","0,000","0,000",0,"0,000","0,000","0,000",908,"0,000","0,000","0,000","00,000,000"
[/text]
How to import csv file with two different field terminated. I use this code
Code: Select all
$connec = mysql_connect('****','****','****');
mysql_select_db('****', $connec);
$sql = "LOAD DATA LOCAL INFILE '*****.csv'
INTO TABLE myworksheet
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY ';'
LINES TERMINATED BY '\r\n'
IGNORE 1 LINES
";
mysql_query($sql);
This is my row from csv file.
[text]
401,1,colomn4,500053;example1;0000000585;21.07.2011,,,,"0,000","0,000","0,000","00,000,000","0,000","0,000","0,000",0,"0,000","0,000","0,000","0,908","0,000","0,000","0,000",0,"0,000","0,000","0,000",0,"0,000","0,000","0,000",0,"0,000","0,000","0,000",908,"0,000","0,000","0,000","00,000,000"
[/text]