Page 1 of 1

CSV into mysql

Posted: Sat Mar 19, 2005 6:51 pm
by ecaandrew
Does anyone know how to insert a CSV file into mysql? thanks!

Posted: Sat Mar 19, 2005 7:11 pm
by zylinder
Do you want to store the whole file or the values between your delimiters?

Posted: Sat Mar 19, 2005 7:21 pm
by ecaandrew
the whole file, its about 3.5 mb's

Posted: Sat Mar 19, 2005 8:01 pm
by zylinder
I thought you just have to use the php function file_get_contents(foo.cvs)
and save it in a largetext or largeblob field. But after some testing I found out
(as you already might know) that strings larger than 1024 kB wont be saved.

MySQL just ignores the query and does not return an error msg.

Thanx to g 8O gle I found this.

http://perlmonks.thepen.com/150255.html

Hope this helps

Posted: Sat Mar 19, 2005 8:36 pm
by hawleyjr
As I said in PM use: LOAD DATA INFILE

http://dev.mysql.com/doc/mysql/en/load-data.html

Posted: Sat Mar 19, 2005 9:52 pm
by ecaandrew
its not working, ive tryed everything

the .CSV file starts like this

zip,city,county,state,areacode,fips,timezone,dst,latitude,longitude
"00501","Holtsville","Suffolk","NY","631","36103","EST","Y","40.8151","-73.045


but yeh ive tryed that , it only inserts like like the first field