CSV into mysql

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
ecaandrew
Forum Commoner
Posts: 72
Joined: Fri Nov 12, 2004 5:05 pm

CSV into mysql

Post by ecaandrew »

Does anyone know how to insert a CSV file into mysql? thanks!
zylinder
Forum Newbie
Posts: 9
Joined: Thu Feb 17, 2005 1:27 pm
Location: Austria

Post by zylinder »

Do you want to store the whole file or the values between your delimiters?
ecaandrew
Forum Commoner
Posts: 72
Joined: Fri Nov 12, 2004 5:05 pm

Post by ecaandrew »

the whole file, its about 3.5 mb's
zylinder
Forum Newbie
Posts: 9
Joined: Thu Feb 17, 2005 1:27 pm
Location: Austria

Post 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
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

As I said in PM use: LOAD DATA INFILE

http://dev.mysql.com/doc/mysql/en/load-data.html
ecaandrew
Forum Commoner
Posts: 72
Joined: Fri Nov 12, 2004 5:05 pm

Post 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
Post Reply