From 7c755d00d9c22a156c203f3f2b3312bdb583b5ce Mon Sep 17 00:00:00 2001 From: prathamesh Date: Fri, 10 Nov 2017 16:04:32 +0530 Subject: Optimised the code and added dialect while reading to handle different delimiters --- yaksh/file_utils.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'yaksh/file_utils.py') diff --git a/yaksh/file_utils.py b/yaksh/file_utils.py index 0d80b8f..7aef249 100644 --- a/yaksh/file_utils.py +++ b/yaksh/file_utils.py @@ -52,6 +52,7 @@ def extract_files(zip_file, path=None): def is_csv(document): + ''' Check if document is csv with ',' as the delimiter''' try: try: content = document.read(1024).decode('utf-8') @@ -62,8 +63,8 @@ def is_csv(document): dialect = sniffer.sniff(content) document.seek(0) except (csv.Error, UnicodeDecodeError): - return False - return True + return False, None + return True, dialect def headers_present(dict_reader, headers): -- cgit