ダウンロードと解凍について

json.gzで終わるファイルのダウンロードと解凍が上手くいきません。
なぜなのでしょうか。

In [2]: !curl -O http://openrecipes.s3.amazonaws.com/recipeitems-latest.json.gz
...: !gunzip recipeitems-latest.json.gz

% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 20 100 20 0 0 50 0 --:--:-- --:--:-- --:--:-- 51

In [3]: with open('recipeitems-latest.json') as f:
...: line = f.readline()
...: pd.read_json(line).shape

ValueError Traceback (most recent call last)
Input In [4], in <cell line: 3>()
1 with open('recipeitems-latest.json') as f:
2 line = f.readline()
----> 3 pd.read_json(line).shape

File ~/miniconda3/lib/python3.8/site-packages/pandas/util/_decorators.py:207, in deprecate_kwarg.<locals>._deprecate_kwarg.<locals>.wrapper(*args, **kwargs)
205 else:
206 kwargs[new_arg_name] = new_arg_value
--> 207 return func(*args, **kwargs)

File ~/miniconda3/lib/python3.8/site-packages/pandas/util/_decorators.py:311, in deprecate_nonkeyword_arguments.<locals>.decorate.<locals>.wrapper(*args, **kwargs)
305 if len(args) > num_allow_args:
306 warnings.warn(
307 msg.format(arguments=arguments),
308 FutureWarning,
309 stacklevel=stacklevel,
310 )
--> 311 return func(*args, **kwargs)

File ~/miniconda3/lib/python3.8/site-packages/pandas/io/json/_json.py:612, in read_json(path_or_buf, orient, typ, dtype, convert_axes, convert_dates, keep_default_dates, numpy, precise_float, date_unit, encoding, encoding_errors, lines, chunksize, compression, nrows, storage_options)
609 return json_reader
611 with json_reader:
--> 612 return json_reader.read()

File ~/miniconda3/lib/python3.8/site-packages/pandas/io/json/_json.py:746, in JsonReader.read(self)
744 obj = self._get_object_parser(self._combine_lines(data_lines))
745 else:
--> 746 obj = self._get_object_parser(self.data)
747 self.close()
748 return obj

File ~/miniconda3/lib/python3.8/site-packages/pandas/io/json/_json.py:768, in JsonReader._get_object_parser(self, json)
766 obj = None
767 if typ == "frame":
--> 768 obj = FrameParser(json, **kwargs).parse()
770 if typ == "series" or obj is None:
771 if not isinstance(dtype, bool):

File ~/miniconda3/lib/python3.8/site-packages/pandas/io/json/_json.py:880, in Parser.parse(self)
878 self._parse_numpy()
879 else:
--> 880 self._parse_no_numpy()
882 if self.obj is None:
883 return None

File ~/miniconda3/lib/python3.8/site-packages/pandas/io/json/_json.py:1133, in FrameParser._parse_no_numpy(self)
1129 orient = self.orient
1131 if orient == "columns":
1132 self.obj = DataFrame(
-> 1133 loads(json, precise_float=self.precise_float), dtype=None
1134 )
1135 elif orient == "split":
1136 decoded = {
1137 str(k): v
1138 for k, v in loads(json, precise_float=self.precise_float).items()
1139 }

ValueError: Expected object or value

コメントを投稿

0 コメント