[issue24503] csv.writer fails when within csv.reader

2015-07-22 Thread Wolfgang E. Sanyer

Wolfgang E. Sanyer added the comment:

You can close this - it turns out that I was looping through the input file 
once first, and did not properly rewind it after doing so.

Might it make sense to have the csv module rewind the file after it has been 
looped through, so that it acts as a typical list?

--
status: open -> closed

___
Python tracker 
<http://bugs.python.org/issue24503>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24503] csv.writer fails when within csv.reader

2015-06-24 Thread Wolfgang E. Sanyer

New submission from Wolfgang E. Sanyer:

I have a use case where I am using a csv.reader to loop through one file and 
trying to use a csv.writer to output to another file. However, when I do this, 
the csv.writer instance does not write anything to the output file.

ex:

import csv

with open("input.csv", "rb") as input, open("output.csv", "wb") as output:
reader = csv.reader(input)
writer = csv.writer(output)

for row in reader:
writer.writerow("data") # this writes out nothing

writer.writerow("more data") # this writes out something

--
components: Library (Lib)
messages: 245772
nosy: ezzieyguywuf
priority: normal
severity: normal
status: open
title: csv.writer fails when within csv.reader
type: behavior
versions: Python 2.7

___
Python tracker 
<http://bugs.python.org/issue24503>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com