From 4b0c7223fe54117e69d86c43b5f73380ce3e49d7 Mon Sep 17 00:00:00 2001 From: nikhilrp Date: Thu, 9 Apr 2015 13:21:26 -0700 Subject: [PATCH 1/4] hot fix --- src/encoded/loadxl.py | 4 ++-- src/encoded/typedsheets.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/encoded/loadxl.py b/src/encoded/loadxl.py index 38e692a84ff..450c3b52958 100644 --- a/src/encoded/loadxl.py +++ b/src/encoded/loadxl.py @@ -174,7 +174,7 @@ def read_single_sheet(path, name=None): if name is None: root, ext = os.path.splitext(path) - stream = open(path, 'rb') + stream = open(path, 'r') if ext == '.xlsx': return read_xl(stream) @@ -191,7 +191,7 @@ def read_single_sheet(path, name=None): raise ValueError('Unknown file extension for %r' % path) if path.endswith('.xlsx'): - return cast_row_values(xlreader.DictReader(open(path, 'rb'), sheetname=name)) + return cast_row_values(xlreader.DictReader(open(path, 'r'), sheetname=name)) if path.endswith('.zip'): zf = ZipFile(path) diff --git a/src/encoded/typedsheets.py b/src/encoded/typedsheets.py index b961437c73d..82d80687918 100644 --- a/src/encoded/typedsheets.py +++ b/src/encoded/typedsheets.py @@ -12,7 +12,7 @@ def parse_object(types, value): def parse_string(types, value): assert not types - return value.decode('utf-8') + return value def parse_ignore(types, value): From 0f4f035dae6cf6c48677a193f8b9cbb3e6c8256f Mon Sep 17 00:00:00 2001 From: nikhilrp Date: Thu, 9 Apr 2015 14:09:56 -0700 Subject: [PATCH 2/4] Xlsx fix --- src/encoded/loadxl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/encoded/loadxl.py b/src/encoded/loadxl.py index 450c3b52958..42fe2401a0a 100644 --- a/src/encoded/loadxl.py +++ b/src/encoded/loadxl.py @@ -191,7 +191,7 @@ def read_single_sheet(path, name=None): raise ValueError('Unknown file extension for %r' % path) if path.endswith('.xlsx'): - return cast_row_values(xlreader.DictReader(open(path, 'r'), sheetname=name)) + return cast_row_values(xlreader.DictReader(open(path, 'rb'), sheetname=name)) if path.endswith('.zip'): zf = ZipFile(path) From 77b1687ec6df4159a6fb5b1859fa4d32b4a9d975 Mon Sep 17 00:00:00 2001 From: nikhilrp Date: Thu, 9 Apr 2015 17:36:25 -0700 Subject: [PATCH 3/4] Fix for json files --- src/encoded/loadxl.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/encoded/loadxl.py b/src/encoded/loadxl.py index 42fe2401a0a..deeb7452595 100644 --- a/src/encoded/loadxl.py +++ b/src/encoded/loadxl.py @@ -246,10 +246,8 @@ def read_csv(stream, **kw): def read_json(stream): - import codecs import json - utf8 = codecs.getreader('utf-8') - obj = json.load(utf8(stream)) + obj = json.load(stream) if isinstance(obj, dict): return [obj] return obj From 5fed62de5f0093dfd2397eddb95c6e5290898221 Mon Sep 17 00:00:00 2001 From: nikhilrp Date: Thu, 9 Apr 2015 18:09:13 -0700 Subject: [PATCH 4/4] more changes --- src/encoded/loadxl.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/encoded/loadxl.py b/src/encoded/loadxl.py index deeb7452595..e88b84d846a 100644 --- a/src/encoded/loadxl.py +++ b/src/encoded/loadxl.py @@ -221,15 +221,15 @@ def read_single_sheet(path, name=None): return read_xl(stream) if os.path.exists(root + '.tsv'): - stream = open(root + '.tsv', 'rbU') + stream = open(root + '.tsv', 'rU') return read_csv(stream, dialect='excel-tab') if os.path.exists(root + '.csv'): - stream = open(root + '.csv', 'rbU') + stream = open(root + '.csv', 'rU') return read_csv(stream) if os.path.exists(root + '.json'): - stream = open(root + '.json', 'rb') + stream = open(root + '.json', 'r') return read_json(stream) return []