Jump to content

Another way to read a file into an array


iceblox

Recommended Posts

Its quite a lengthy script which works however when the file is large the server runs out of memory and its running on max memory!

 

I had some code which basically reads and replaces 12500 lines then starts at 12501 til 25000. If this makes sense?

 

I believe file opens the whole file and i think thats what the problem is..  So what i was hoping to find was a func that would alllow this to work without re writing the whole script?

 

Thanks again Phil

reads and replaces 12500 lines ... If this makes sense?

No, that does not make 'computer' sense. After you have a few thousand lines of data, you should migrate it to a database and let the database engine do the work for you.

reads and replaces 12500 lines ... If this makes sense?

No, that does not make 'computer' sense. After you have a few thousand lines of data, you should migrate it to a database and let the database engine do the work for you.

 

That might not be applicable. What if he is writing a script to analyze Apache access logs for instance? What if he is writing the script that is migrating to a DBMS?

 

Check this out:

[daniel@phpfreaks logs]$ wc -l access.log.2009-09-25
681486 access.log.2009-09-25

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.