Modify text file.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How can I modify values in text file? File is tab delimited as follows

Date Buy Sell
13-Jan-2005 0.9970776 0.9901224
18-Jan-2005 0.9910566 0.9841434

I want to modify Buy and Sell values for a particular Date.

Thanks
 
You can read the file in as a string and then use standard string
manipulation and/or regexes on it - or you can load those values into an
array/collection and manipulate them from there.
 
Hi Ryan

Once I have loaded values into array/collection and made chnages, how would
I writes those changed values back to the text file at the same line number?
 
Job Lot said:
Once I have loaded values into array/collection and made chnages, how would
I writes those changed values back to the text file at the same line number?

Unless the lines are fixed length, you'll have to rewrite the whole
file - or at least the whole file from the change point onwards.
There's no way of deleting or inserting characters into a file.
 
Back
Top