Re: Parse info from 1,000 files to file

From: Date: Fri, 04 Jun 2010 13:35:21 +0000
Subject: Re: Parse info from 1,000 files to file
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-305818@lists.php.net to get a copy of this message
At 5:03 PM -0700 6/3/10, Jim Lucas wrote:
Sam Smith wrote:
Can someone briefly point me to the functions I'll need to parse some information from thousands of files in a single directory and then prepare the extracted info into a single file for SQL import? Like file() or readfile() and some regex and writefile?? since you did not say what type of data was in the files, I will assume it is CSV data in my example. -snip- Another option that you could add to this is instead of cleaning your data and inserting it into your DB, you could create a tmp file that all the data in shoved into. Then, once you are done processing all the original files, you could then insert the data into your database with its LOAD FILE option. -- Jim Lucas
Jim: To continue your suggestion, the OP could try this: LOAD DATA LOCAL INFILE '/myfile.csv' INTO TABLE mytable FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n' (field1, filed2, field3); PHP is much slower than MySQL for importing CVS files. See: http://dev.mysql.com/doc/refman/5.1/en/load-data.html Cheers, tedd -- ------- http://sperling.com http://ancientstones.com http://earthstones.com

« previous php.general (#305818) next »