From 1e6e44f656f1bbb277eb38fb485f7b48e3b9e40b Mon Sep 17 00:00:00 2001 From: Kelly Brazil Date: Mon, 25 Oct 2021 11:03:21 -0700 Subject: [PATCH] fix for piping data with non-platform newlines (e.g. windows csv files on unix) --- jc/parsers/csv_s.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/jc/parsers/csv_s.py b/jc/parsers/csv_s.py index 9a8c3383..725cdf92 100644 --- a/jc/parsers/csv_s.py +++ b/jc/parsers/csv_s.py @@ -104,6 +104,11 @@ def parse(data, raw=False, quiet=False, ignore_exceptions=False): for line in itertools.islice(data, 100): 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) dialect = None