Reputation: 169
I have the following simple json in a file saved as notepad file t.json
[{"a": 1, "b": 2, "c": 3},
{"a": 4, "b": 5, "c": 6},
{"a": 7, "b": 8, "c": 9}]
I am trying to open it using
ValueError Traceback (most recent call last)
<ipython-input-236-487720f2328b> in <module>()
----> 1 data = pd.read_json('t.json')
~\Anaconda3\lib\site-packages\pandas\io\json\json.py in read_json(path_or_buf, orient, typ, dtype, convert_axes, convert_dates, keep_default_dates, numpy, precise_float, date_unit, encoding, lines, chunksize, compression)
420 return json_reader
421
--> 422 result = json_reader.read()
423 if should_close:
424 try:
~\Anaconda3\lib\site-packages\pandas\io\json\json.py in read(self)
527 )
528 else:
--> 529 obj = self._get_object_parser(self.data)
530 self.close()
531 return obj
~\Anaconda3\lib\site-packages\pandas\io\json\json.py in _get_object_parser(self, json)
544 obj = None
545 if typ == 'frame':
--> 546 obj = FrameParser(json, **kwargs).parse()
547
548 if typ == 'series' or obj is None:
~\Anaconda3\lib\site-packages\pandas\io\json\json.py in parse(self)
636
637 else:
--> 638 self._parse_no_numpy()
639
640 if self.obj is None:
~\Anaconda3\lib\site-packages\pandas\io\json\json.py in _parse_no_numpy(self)
851 if orient == "columns":
852 self.obj = DataFrame(
--> 853 loads(json, precise_float=self.precise_float), dtype=None)
854 elif orient == "split":
855 decoded = {str(k): v for k, v in compat.iteritems(
ValueError: Expected object or value
I have tried creating an absolute path as per the suggestion in this page but it also produces a value error. Can anyone help please?
Upvotes: 1
Views: 6242
Reputation: 515
There is a possibility this is a bug of pandas module. What version are you using? Consider updating.
After that you can try the following:
data = pd.read_json('t.json', lines=False)
Hope it helps
Upvotes: 2