Re: How do I read and write to the same CSV file

2007-09-10 Thread Steven D'Aprano
On Mon, 10 Sep 2007 15:01:32 +, Steven D'Aprano wrote: > But if you insist... you might be able to use cf_stream.seek() to move > to the current position in the file, then write the bytes you want. How > do you find the current position? Black magic or voodoo might help. Well, that'll learn

Re: How do I read and write to the same CSV file

2007-09-10 Thread Steven D'Aprano
On Mon, 10 Sep 2007 07:27:46 -0700, Chris wrote: > I want to update one field in a row for a csv file. So far my code looks > something like this > > cf_stream = open("\\config.csv","r+") > csv_file = csv.DictReader(cf_stream, ['Algorithm','LastModified']) > > and then I know I can do something

Re: How do I read and write to the same CSV file

2007-09-10 Thread Marc 'BlackJack' Rintsch
On Mon, 10 Sep 2007 07:27:46 -0700, Chris wrote: > if date == 0: > date = os.getmtime() > # now this is where I want to write into the row of the same csv > file but only updating that one field > > How can I do this? You can't. Modifying text files with variable length lines is "im

How do I read and write to the same CSV file

2007-09-10 Thread Chris
I want to update one field in a row for a csv file. So far my code looks something like this cf_stream = open("\\config.csv","r+") csv_file = csv.DictReader(cf_stream, ['Algorithm','LastModified']) and then I know I can do something like this for row in csv_file name = row["Algorithm"]