PHP Help
I want a script to split the large CSV file (more thans 50MB) into multiple CSV file of each not more than 9MB.
Anyone having script ... Help Me. Thanks Malar. |
Quote:
Check php.net for a list of functions. |
Also, there's a standard Unix command called "split" that might be exactly what you're looking for.
Type "man split", or Google "linux split command" for details. Good luck .. PSM |
The challenge is approximating size of file, depending on how much data is on a single line of the input CSV, will determine how many lines get copied to each output file.
Since CSV files are mostly single line per record, line oriented, you could try reading the input file, copying the character out to the 'current' output file, say out_1.csv, while building a count of characters read. On reading each new line evaluate if the character size read so far has exceeded the desired size of output file. If so, close the file and open a new out_2.csv and repeat until no more input file. |
http://www.php.net/manual-lookup.php?pattern=csv reveals:
fputcsv fgetcsv str_getcsv Never used them but it sounds like they will do the trick. Please pay attention to the version of PHP required for each of the above functions. |
Quote:
|
All times are GMT -5. The time now is 04:41 PM. |