Revision 5587
Added by Aaron Marcuse-Kubitza about 12 years ago
lib/csvs.py | ||
---|---|---|
159 | 159 |
try: return self.reader.next() |
160 | 160 |
except StopIteration: return '' # EOF |
161 | 161 |
|
162 |
class InputRewriter: |
|
162 |
class InputRewriter(StreamFilter):
|
|
163 | 163 |
'''Wraps a reader, writing each row back to CSV''' |
164 | 164 |
def __init__(self, reader, dialect=csv.excel): |
165 |
self.reader = reader |
|
165 |
StreamFilter.__init__(self, reader) |
|
166 |
|
|
166 | 167 |
self.dialect = dialect |
167 | 168 |
|
168 | 169 |
def readline(self): |
169 |
try: row = self.reader.next() |
|
170 |
except StopIteration: row = '' # EOF |
|
170 |
row = self.reader.readline() |
|
171 | 171 |
if row == '': return row # EOF |
172 | 172 |
|
173 | 173 |
line_stream = StringIO.StringIO() |
Also available in: Unified diff
csvs.py: InputRewriter: Use new StreamFilter to translate StopIteration EOF to ''