PDA

View Full Version : inserting data from text file (.txt) into mysql database/table


brianellisrules
Jan 24, 2004, 04:37 PM
Howdy.

Using my new-found php/mysql skills, I'm modifying my counter to use a mysql database rather than a text file to track unique hits to my website.

The way it currently works is that it checks the IP of the user against a list of IPs in a text file. If the IP isn't there, increment the counter and add the IP to the list. Otherwise, do nothing.

I've modified it so it does all that using a mysql database (I EVEN WROTE A FUNCTION! WOOHOO!). Now I just need to transfer the data from the text file (over a thousand values) into the mysql database. If it was just a few lines, I'd do it manually via phpmyadmin, but that would take forever and a day for this case.

Thanks!

oingoboingo
Jan 24, 2004, 06:03 PM
The LOAD DATA INFILE command is used to rapidly load data from external text files in MySQL. You should read http://www.mysql.com/documentation/mysql/bychapter/manual_SQL_Syntax.html#LOAD_DATA

Hope this helps. As long as your text data is formatted sensibly (eg: tab or comma delimited or something similar) it should be no problem.

raytube
Jan 24, 2004, 07:25 PM
Hi,
I use Navicat for all my import/export data transfer in MySQL, you can get a 30 day trial, www.navicat.com

It's available for OSX and also Windows.

Essential application in my opinion!

Cheers,

Rick

brianellisrules
Jan 24, 2004, 10:58 PM
Thanks for the responses. It turns out there's an option in phpmyadmin to upload data from a text file. Oops, sorry.