Revision 5586
Added by Aaron Marcuse-Kubitza about 12 years ago
lib/csvs.py | ||
---|---|---|
149 | 149 |
|
150 | 150 |
##### Translators |
151 | 151 |
|
152 |
class StreamFilter(Filter): |
|
153 |
'''Wraps a reader in a way that's usable to a filter stream that does not |
|
154 |
require lines to be strings. Reports EOF as '' instead of StopIteration.''' |
|
155 |
def __init__(self, reader): |
|
156 |
Filter.__init__(self, None, reader) |
|
157 |
|
|
158 |
def readline(self): |
|
159 |
try: return self.reader.next() |
|
160 |
except StopIteration: return '' # EOF |
|
161 |
|
|
152 | 162 |
class InputRewriter: |
153 | 163 |
'''Wraps a reader, writing each row back to CSV''' |
154 | 164 |
def __init__(self, reader, dialect=csv.excel): |
Also available in: Unified diff
csvs.py: Added StreamFilter