#json #excel #converters
#json #excel #конвертеры
Вопрос:
Я хочу выполнить простое преобразование файла из формата JSON в csv или любой другой файл типа «excel».
Я пробовал этот код в записной книжке Jupyter
import json
import csv
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
from tqdm import tqdm, tqdm_notebook, tnrange
# Display Settings
pd.set_option('display.max_columns', 50)
# Importing Review JSON File
reviews = []
with open("/home/datascience/conda/Capstone_Project/Data/yelp_academic_dataset_review_v2.json") as f:
for line in f:
reviews.append(json.loads(line))
# Length of rows of Data
len(reviews) # 8,021,122 reviews
———-Вот где он выдает ошибку ————
JSONDecodeError Traceback (most recent call last)
<ipython-input-45-1797b55414f8> in <module>
5 with open("/home/datascience/conda/Capstone_Project/Data/yelp_academic_dataset_review_v2.json") as f:
6 for line in f:
----> 7 reviews.append(json.loads(line))
8
9 # Length of rows of Data
/opt/conda/lib/python3.6/json/__init__.py in loads(s, encoding, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
352 parse_int is None and parse_float is None and
353 parse_constant is None and object_pairs_hook is None and not kw):
--> 354 return _default_decoder.decode(s)
355 if cls is None:
356 cls = JSONDecoder
/opt/conda/lib/python3.6/json/decoder.py in decode(self, s, _w)
337
338 """
--> 339 obj, end = self.raw_decode(s, idx=_w(s, 0).end())
340 end = _w(s, end).end()
341 if end != len(s):
/opt/conda/lib/python3.6/json/decoder.py in raw_decode(self, s, idx)
353 """
354 try:
--> 355 obj, end = self.scan_once(s, idx)
356 except StopIteration as err:
357 raise JSONDecodeError("Expecting value", s, err.value) from None
JSONDecodeError: Unterminated string starting at: line 1 column 162 (char 161)
Вот откуда я получил эти данные https://github.com/abhinavsaurabh/Restaurant-Recommendation