On Fri, 28 Dec 2007 18:12:58 -0800, t_rectenwald wrote: > Within the program, the snippet where I use the csv module is below: > > ============================== > csvfile = open('foo.csv', 'w') > writer = csv.writer(csvfile) > > for row in rows: > writer.writerow(row[0:3]) > > csvfile.close > ============================== > > The rows object is returned from a database query and is a list of > tuples. Now here is the strange thing. If I run this program > directly from the command line, i.e., > > D:\test> D:\python25\python foo.py > > It runs fine, foo.csv is created and all is well. However, when I run > it through the IDLE shell as described above, the foo.csv file is > created but remains empty at 0 bytes. When I try to delete the file, > Windows says it is in use. The only way I can break out of this is by > restarting the IDLE shell. In other words, it appears that the shell > is hanging. > > This will run through Task Scheduler, so shouldn't be a problem, but > I'm worried that I'm coding this wrong for it to be acting this way > under IDLE. Any help or explanation would be appreciated.
You are not closing the file so the buffered data is not written to disk. To call a function you need the parenthesis, otherwise you are just referencing it without any effect. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list