diff options
author | prathamesh | 2017-11-10 16:04:32 +0530 |
---|---|---|
committer | prathamesh | 2017-11-10 16:04:32 +0530 |
commit | 7c755d00d9c22a156c203f3f2b3312bdb583b5ce (patch) | |
tree | 40b0e2f3aa309f1a6b59c8b41d451ca599053ae1 /yaksh/file_utils.py | |
parent | 886f544ac44d831c7844ca42edb4cb97bc3b6313 (diff) | |
download | online_test-7c755d00d9c22a156c203f3f2b3312bdb583b5ce.tar.gz online_test-7c755d00d9c22a156c203f3f2b3312bdb583b5ce.tar.bz2 online_test-7c755d00d9c22a156c203f3f2b3312bdb583b5ce.zip |
Optimised the code and added dialect while reading to handle different
delimiters
Diffstat (limited to 'yaksh/file_utils.py')
-rw-r--r-- | yaksh/file_utils.py | 5 |
1 files changed, 3 insertions, 2 deletions
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): |