Re: Splitting a CSV file

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

 



try to parse the csv file line by line and you won't have memory problems
ever:
===============================
$d = "\t"; // fields delimiter
$fp = fopen ($file_name, "r");
while ($arr_row = fgetcsv ($fp, 4096, $d, "")) {
    do_something ($arr_row);
}
 fclose ($fp);
===============================
(fgetcsv returns an array containing the fields read.)

Tiberiu


----- Original Message ----- 
From: "Chris Payne" <chris@xxxxxxxxxxxxxxxxx>
To: <php-db@xxxxxxxxxxxxx>
Sent: Tuesday, November 25, 2003 1:14 AM
Subject:  Splitting a CSV file


Hi there everyone,

I'm writing an automation system to automatically insert data into a mysql
database from a CSV file, and it works great - until I try to insert a large
file, then it just doesn't do anything.

I've set my PHP filesize to 10 Megs so that's not the issue, and a server
timeout isn't the issue either.  So, is that a way that I can split a CSV
file into 2 files if it's larger than a certain size so that I can still use
the automation I am working on?

Actually, I won't see the files as it's for a company who just wants to be
able to select their CSV file (No matter what size) and it will insert it
automatically, and as I said it does work on small files but not large :-(

Any help would really be appreciated.

Chris

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


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux