1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-06-17 00:07:37 +02:00

fix for piping data with non-platform newlines (e.g. windows csv files on unix)

This commit is contained in:
Kelly Brazil
2021-10-25 11:03:21 -07:00
parent acac039994
commit 1e6e44f656

View File

@ -104,6 +104,11 @@ def parse(data, raw=False, quiet=False, ignore_exceptions=False):
for line in itertools.islice(data, 100): for line in itertools.islice(data, 100):
temp_list.append(line) temp_list.append(line)
# if length of temp_list is only 1, then was probably piped in with incorrect newline for the platform
# try splitting on lines again:
if len(temp_list) == 1:
temp_list = temp_list[0].splitlines()
sniffdata = '\n'.join(temp_list) sniffdata = '\n'.join(temp_list)
dialect = None dialect = None