[Csv] ignore blank lines?
Skip Montanaro
skip at pobox.com
Wed Feb 12 16:11:06 CET 2003
John> Does Skip mean a blank line "...\n \n..." or an empty line
John> "...\n\n..." ???
I meant a line which consists of just the lineterminator sequence.
Here's my use case. In the DictReader class, if the underlying reader
object returns an empty list and I don't catch it, I wind up returning a
dictionary all of whose fields are set to the restval (typically None). The
caller can't simply compare that against {} as the caller of csv.reader()
can compare the returned value against [], so it makes sense for me to elide
that case in the DictReader code.
I modified DictReader.next() to start like:
def next(self):
row = self.reader.next()
while row == []:
row = self.reader.next()
... process row ...
Does that behavior make sense in this case?
Skip
More information about the Csv
mailing list