Download MetaTrader 5

Adding information to a CSV file

To add comments, please log in or register
OrangeTrading
16
OrangeTrading  

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.

whroeder1
16808
whroeder1  
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.
OrangeTrading
16
OrangeTrading  
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?

whroeder1
16808
whroeder1  
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.
To add comments, please log in or register