Skip to content

Commit

Permalink
fix for demo
Browse files Browse the repository at this point in the history
  • Loading branch information
axiaoxin committed May 28, 2019
1 parent e08b9bc commit 232d131
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions json2xls/json2xls.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,10 @@ def __get_json(self):
if os.path.isfile(self.json_data):
with open(self.json_data, 'r') as source:
try:
data = self.json_loads(
source.read().decode('utf-8').replace('\n', ''))
data = self.json_loads(source.read().replace('\n', ''))
except Exception:
source.seek(0)
data = [
self.json_loads(line.decode('utf-8'))
for line in source
]
data = [self.json_loads(line) for line in source]
else:
if self.headers and os.path.isfile(self.headers):
with open(self.headers) as headers_txt:
Expand All @@ -121,12 +117,13 @@ def __get_json(self):
headers=self.headers)
data = resp.json()
else:
if isinstance(self.post_data,
basestring) and os.path.isfile(
self.post_data):
if isinstance(
self.post_data,
("".__class__, u"".__class__)) and os.path.isfile(
self.post_data):
with open(self.post_data, 'r') as source:
self.post_data = self.json_loads(
source.read().decode('utf-8').replace(
source.read().replace(
'\n', ''))
if not self.form_encoded:
self.post_data = self.json_dumps(self.post_data)
Expand All @@ -149,7 +146,8 @@ def __fill_title(self, data):
self.sheet.col(index).width = (len(key) + 1) * 256
except Exception:
pass
self.sheet.row(self.start_row).write(index, key.decode('utf-8'), self.title_style)
self.sheet.row(self.start_row).write(index, key.decode('utf-8'),
self.title_style)
self.start_row += 1

def __fill_data(self, data):
Expand Down

0 comments on commit 232d131

Please sign in to comment.