Best unofficial Apache Server developers community |
|
Hello, i need help and i need it fast! .. it's pretty self explanatory if you look at the code.. what i NEED this code to do is to create a new CSV and call it output_1.csv, write 100 lines to that CSV, then save it, create output_2.csv, and write up to 100 lines, and continue to create 100 line files until all info is exhausted. can someone help me with this????? This is what i have to work with. At the moment, it just writes to 1 file until everything is exhausted. truthfully, i need this to do 100,000 lines at a time, but for testing purposes, 100 is fine, i can change it. PLEASE PLEASE HELP. i've maxed out my deadline for this! thanks in advance!! by the way.. yeah, im sure your eyes got big when i said 100,000 lines.......... i know.............. i know... but that's what i need. we have about 8 million things i need to split up. take too long to explain, just help me get it done please please.
posted via StackOverflow
|
|
 
|
You can do that easily by keeping a counter variable.
The last line replaces your fopen/fwrite/fclose construct. |
|
 
|
This is very basic stuff. A simple "state machine" will do this for you:
Basically, open a file, then starting writing out lines. If the # of lines written is a multiple of 100, close the previous file, open a new one, and keep on going with a new filename. REpeat until done, then close the last file. |