Re: CSV writer question

2011-10-24 Thread Peter Otten
Jason Swails wrote: > Hello, > > I have a question about a csv.writer instance. I have a utility that I > want to write a full CSV file from lots of data, but due to performance > (and memory) considerations, there's no way I can write the data > sequentially. Therefore, I write the data in chun

Re: CSV writer question

2011-10-24 Thread Andrew McLean
On 24/10/2011 08:03, Chris Angelico wrote: On Mon, Oct 24, 2011 at 4:18 PM, Jason Swails wrote: my_csv = csv.writer(open('temp.1.csv', 'wb')) Have you confirmed, or can you confirm, whether or not the file gets closed automatically when the writer gets destructed? If so, all you need to do is

Re: CSV writer question

2011-10-24 Thread Jason Swails
On Mon, Oct 24, 2011 at 3:03 AM, Chris Angelico wrote: > On Mon, Oct 24, 2011 at 4:18 PM, Jason Swails > wrote: > > my_csv = csv.writer(open('temp.1.csv', 'wb')) > > > > Have you confirmed, or can you confirm, whether or not the file gets > closed automatically when the writer gets destructed? I

Re: CSV writer question

2011-10-24 Thread Jason Swails
On Mon, Oct 24, 2011 at 2:08 AM, Chris Rebert wrote: > On Sun, Oct 23, 2011 at 10:18 PM, Jason Swails > wrote: > > > unless, of course, I add an explicit reference to track the open file > object > > and manually close or flush it > > (but I'd like to avoid it if possible). > > Why? Especially w

Re: CSV writer question

2011-10-24 Thread Chris Angelico
On Mon, Oct 24, 2011 at 4:18 PM, Jason Swails wrote: > my_csv = csv.writer(open('temp.1.csv', 'wb')) > Have you confirmed, or can you confirm, whether or not the file gets closed automatically when the writer gets destructed? If so, all you need to do is: my_csv = something_else # or: del my_csv

Re: CSV writer question

2011-10-23 Thread Chris Rebert
On Sun, Oct 23, 2011 at 10:18 PM, Jason Swails wrote: > Hello, > > I have a question about a csv.writer instance.  I have a utility that I want > to write a full CSV file from lots of data, but due to performance (and > memory) considerations, there's no way I can write the data sequentially. > Th

CSV writer question

2011-10-23 Thread Jason Swails
Hello, I have a question about a csv.writer instance. I have a utility that I want to write a full CSV file from lots of data, but due to performance (and memory) considerations, there's no way I can write the data sequentially. Therefore, I write the data in chunks to temporary files, then combi