|
@@ -229,16 +229,17 @@ def field_values_from_separated_file(fh, delimiter, quote_character, fields=None
|
|
|
while content:
|
|
while content:
|
|
|
last_newline = content.rfind('\n')
|
|
last_newline = content.rfind('\n')
|
|
|
if last_newline > -1:
|
|
if last_newline > -1:
|
|
|
|
|
+ next_chunk = fh.read()
|
|
|
# If new line is quoted, skip this iteration and try again.
|
|
# If new line is quoted, skip this iteration and try again.
|
|
|
- if content[:last_newline].count('"') % 2 != 0:
|
|
|
|
|
- content += fh.read()
|
|
|
|
|
|
|
+ if content[last_newline - 1] == '"' and next_chunk:
|
|
|
|
|
+ content += next_chunk
|
|
|
continue
|
|
continue
|
|
|
else:
|
|
else:
|
|
|
if headers is None:
|
|
if headers is None:
|
|
|
csvfile = StringIO.StringIO(content[:last_newline])
|
|
csvfile = StringIO.StringIO(content[:last_newline])
|
|
|
else:
|
|
else:
|
|
|
csvfile = StringIO.StringIO('\n' + content[:last_newline])
|
|
csvfile = StringIO.StringIO('\n' + content[:last_newline])
|
|
|
- content = content[last_newline + 1:] + fh.read()
|
|
|
|
|
|
|
+ content = content[last_newline + 1:] + next_chunk
|
|
|
else:
|
|
else:
|
|
|
if headers is None:
|
|
if headers is None:
|
|
|
csvfile = StringIO.StringIO(content)
|
|
csvfile = StringIO.StringIO(content)
|