How I could to modify a existing row with CSVWriter?

50 views
Skip to first unread message

Roberto Cano Duran

unread,
Oct 13, 2012, 9:27:25 AM10/13/12
to csv...@googlegroups.com
Hello,
I'm trying to modify a row with CSVWriter, but I only know how append a row.
Are there any possibility to modify a existing row of the csv file?
Thanks,

shriop

unread,
Oct 15, 2012, 8:48:05 AM10/15/12
to csv...@googlegroups.com
You would have to use both CsvReader and CsvWriter. You would read the file line by line, writing the contents out to a new file. When you read the line that you're looking to modify, you would write out the modified version instead. Then when you're done, you'd delete the old file and rename the new file to the old files name. You could use the same file without the temporary file only if you can store the entire file contents in memory, by calling ReadToEnd on CsvReader for example.

Bruce Dunwiddie
Reply all
Reply to author
Forward
0 new messages