Jump to content

.CVS Import Problem


dragonusthei

Recommended Posts

Im importing the following:

 

"33996344","33996351","GB","GBR","UNITED KINGDOM"

"50331648","69956103","US","USA","UNITED STATES"

"69956104","69956111","BM","BMU","BERMUDA"

"69956112","83886079","US","USA","UNITED STATES"

"94585424","94585439","SE","SWE","SWEDEN"

 

The Current PHP Reads:

 

mysql_query("LOAD DATA LOCAL INFILE 'ip-to-country.csv' 
INTO TABLE ipcountry FIELDS TERMINATED BY ',' ENCLOSED BY '\"'");

 

However this is going wrong after the end of the line because theres no , how can i get round this?

Link to comment
https://forums.phpfreaks.com/topic/69341-cvs-import-problem/
Share on other sites

$query = "LOAD DATA LOCAL INFILE 'ip-to-country.csv' INTO TABLE ipcountry FIELDS TERMINATED BY ',' ENCLOSED BY '\"' LINES TERMINATED BY '\r\n'";

 

the lines terminated by looks for the Return (\r\n) on the line

 

from the manual:

Note that if you created the file on Windows with an editor that uses \r\n as a line terminator, you should use:

mysql> LOAD DATA LOCAL INFILE '/path/pet.txt' INTO TABLE pet

    -> LINES TERMINATED BY '\r\n';

Link to comment
https://forums.phpfreaks.com/topic/69341-cvs-import-problem/#findComment-348411
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.