Uploading .csv or .txt files to populate an existing sql tbl
Moderator: General Moderators
- edawson003
- Forum Contributor
- Posts: 133
- Joined: Thu Aug 20, 2009 6:34 am
- Location: Los Angeles, CA - USA
Uploading .csv or .txt files to populate an existing sql tbl
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
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
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
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
- edawson003
- Forum Contributor
- Posts: 133
- Joined: Thu Aug 20, 2009 6:34 am
- Location: Los Angeles, CA - USA
Re: Uploading .csv or .txt files to populate an existing sql tbl
Ok, cool. I will look into both options. Thank you much!