Page 1 of 1

Uploading .csv or .txt files to populate an existing sql tbl

Posted: Fri Sep 25, 2009 10:56 pm
by edawson003
I would like to build functionality that would allow my admin users the ability to upload .csv or .txt files with a specified numbers of columns (and data types) and column titles to populate an existing mysql table. Does anyone know of a tutorial or something I can follow to set something like this up?

Re: Uploading .csv or .txt files to populate an existing sql tbl

Posted: Sat Sep 26, 2009 12:38 am
by Robert07
Hello,
I've written a post about this subject at http://www.goodfeelingplace.com/free-md ... onversion/, where I discussed how I took an access mdb file, exported it to a text file, then created a script (which you can download there) which would create sql statements that could be copied into phpmyadmin and run. For your application, you could take my script and modify it to actually run the sql against your database instead of printing it out.
Regards,
Robert

Re: Uploading .csv or .txt files to populate an existing sql tbl

Posted: Sat Sep 26, 2009 12:45 am
by Eran
You can import CSV and text files directly into mysql using LOAD DATA INFILE - http://dev.mysql.com/doc/refman/5.1/en/load-data.html

Re: Uploading .csv or .txt files to populate an existing sql tbl

Posted: Sat Sep 26, 2009 1:15 am
by edawson003
Ok, cool. I will look into both options. Thank you much!