diff --git a/roundup/rcsv.py b/roundup/rcsv.py
index da6a0a62f0a74bea0777f93374bd10b21b612e6c..91a8125dc7a2482ee75871823307945ea470cef7 100644 (file)
--- a/roundup/rcsv.py
+++ b/roundup/rcsv.py
-"""
-Supplies a Python-2.3 Object Craft csv module work-alike to the extent
+"""Supplies a Python-2.3 Object Craft csv module work-alike to the extent
needed by Roundup using the Python 2.3 csv module.
-
"""
+__docformat__ = 'restructuredtext'
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')