RichardRotterdam Posted January 28, 2008 Share Posted January 28, 2008 Hi, I am trying to download a csv from a remote server. Loading data from a remote server isnt a problem but the CSV file I am trying to download is very big and i get a fatal error everytime i try to load the whole thing in a variable. Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 17664191 bytes) the url of the CSV file is http://xml.ds1.nl/getcsv/?wi=58654&si=510&xid=83&ws= is storing all this data in a php var even possible? Quote Link to comment https://forums.phpfreaks.com/topic/88194-csv-file-fatal-error/ Share on other sites More sharing options...
laffin Posted January 28, 2008 Share Posted January 28, 2008 download it parse it store entries in a db use functions fopen/fgets/fclose fgets grabs a single line from the file, so u can explode it into an array. $entry=explode(';',$row); than store it in a local db Mysql/Sqlite or similar Quote Link to comment https://forums.phpfreaks.com/topic/88194-csv-file-fatal-error/#findComment-451269 Share on other sites More sharing options...
RichardRotterdam Posted January 28, 2008 Author Share Posted January 28, 2008 even when stored on the local computer as a csv file it's too big to pass as a php string any ideas how to handle a large file Quote Link to comment https://forums.phpfreaks.com/topic/88194-csv-file-fatal-error/#findComment-451273 Share on other sites More sharing options...
laffin Posted January 28, 2008 Share Posted January 28, 2008 reason u use fgets ur not loading the entire file into memory, you are parsing it a section at a time fgets gets one line from the file Quote Link to comment https://forums.phpfreaks.com/topic/88194-csv-file-fatal-error/#findComment-451277 Share on other sites More sharing options...
PFMaBiSmAd Posted January 28, 2008 Share Posted January 28, 2008 For a csv file, using fgetcsv would kill two birds with one stone - http://php.net/fgetcsv Quote Link to comment https://forums.phpfreaks.com/topic/88194-csv-file-fatal-error/#findComment-451280 Share on other sites More sharing options...
RichardRotterdam Posted January 28, 2008 Author Share Posted January 28, 2008 Thanks now that is something I can use I'll look in to this and tell wether I made it work or not Quote Link to comment https://forums.phpfreaks.com/topic/88194-csv-file-fatal-error/#findComment-451294 Share on other sites More sharing options...
laffin Posted January 28, 2008 Share Posted January 28, 2008 lol php never ceases to amaze me by sheer amount of functions it has for doing things. Quote Link to comment https://forums.phpfreaks.com/topic/88194-csv-file-fatal-error/#findComment-451295 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.