Skip to content

Commit

Permalink
Merge pull request #712 from ENCODE-DCC/import_data_fix
Browse files Browse the repository at this point in the history
Import data fix
  • Loading branch information
nikhilRP committed Apr 10, 2015
2 parents 364810b + 5fed62d commit f4901e7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
12 changes: 5 additions & 7 deletions src/encoded/loadxl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 []
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/encoded/typedsheets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit f4901e7

Please sign in to comment.