Adding information to a CSV file

 

Hi guys,

I wish to read through csv files and then write info directly after the read info. 


Now, I know how to read through the CSV file, but I don't know how I can:

-move downwards in the csv file

-then go back to a specific point

-then add data next to the current data


Any help would be so much appreciated.


            
 
OrangeTrading: I wish to read through csv files and then write info directly after the read info.
You can't modify existing lines (changing their size,) only add past the end. Read all lines in to an array, modify the array, and seek to the beginning of the file and write everything.
 
whroeder1:
You can't modify existing lines (changing their size,) only add past the end. Read all lines in to an array, modify the array, and seek to the beginning of the file and write everything.

Thanks for your reply.

The thing is, there are multi millions of lines in the CSV files. Putting it all in arrays would take lots of RAM. 

Is there any other way?

 
OrangeTrading: here are multi millions of lines in the CSV files. Putting it all in arrays would take lots of RAM. Is there any other way?
  1. Read a line, write a modified line to a temp file; repeat. Delete the original file and rename the temp file.
  2. Alternatively use a binary file, no change in size required. Remember the location, read, modify, seek, write; repeat.
Reason: