summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8cd8e3e)
raw | patch | inline | side by side (parent: 8cd8e3e)
author | jlgijsbers <jlgijsbers@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Fri, 24 Oct 2003 16:29:17 +0000 (16:29 +0000) | ||
committer | jlgijsbers <jlgijsbers@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Fri, 24 Oct 2003 16:29:17 +0000 (16:29 +0000) |
removes all empty lines, as both csv parsers barf on them (bug #821364).
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@1931 57a73879-2fb5-44c3-a270-3262357dd7e2
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@1931 57a73879-2fb5-44c3-a270-3262357dd7e2
roundup/rcsv.py | patch | blob | history |
diff --git a/roundup/rcsv.py b/roundup/rcsv.py
index da6a0a62f0a74bea0777f93374bd10b21b612e6c..8957e3540619afc2a6020865c938cd3f7742b5e4 100644 (file)
--- a/roundup/rcsv.py
+++ b/roundup/rcsv.py
"""
from roundup.i18n import _
+from cStringIO import StringIO
error = """Sorry, you need a module compatible with the csv module.
Either upgrade your Python to 2.3 or later, or get and install
the csv module from:
try:
import csv
try:
- reader = csv.reader
+ _reader = csv.reader
writer = csv.writer
excel = csv.excel
error = ''
pass
if hasattr(csv, 'parser'):
error = ''
- def reader(fileobj, dialect=excel):
+ def _reader(fileobj, dialect=excel):
# note real readers take an iterable but 2.1 doesn't
# support iterable access to file objects.
result = []
class comma_separated(excel):
delimiter = ','
+def reader(fileobject, dialect=excel):
+ csv_lines = [line for line in fileobject.readlines() if line.strip()]
+ return _reader(StringIO(''.join(csv_lines)), dialect)
if __name__ == "__main__":
f=open('testme.txt', 'r')