Re: Parse info from 1,000 files to file

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux