View Single Post
Old 01-10-2011, 03:51 AM  
Angry Jew Cat - Banned for Life
(felis madjewicus)
 
Industry Role:
Join Date: Jul 2006
Location: In Mom & Dad's Basement
Posts: 20,368
Quote:
Originally Posted by Kiopa_Matt View Post
Find a better way to do it. Load all that info into a mySQL database, open the file and read it line by line, or something. You shouldn't load a 20MB file into memory if you can avoid it. Script will probably still work, but no point in straining your server resources like that.
How would I go about loading the entire text file line by line straight into the database? That would certainly make things a lot easier.

What I was aiming for was loading the file into an array and then looping through the array and entering all the values into the database, parsing data out of each line in the text and then putting it into the database in the specified columns for each item.

Hitting Google now, and looking at BULK INSERT for importing to SQL. The format of the lines I'm inserting isn't that of a typical CSV, there's several values delimited by different characters. Like one value sperated from the next by a period, then that one sperated from the next by a comma, and then by a space, yadda yadda. So I guess I would have to modify the text file beforehand, and the BULK INSERT?
Angry Jew Cat - Banned for Life is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote