Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Expected object or value error while reading json file in python

path = '/content/drive/MyDrive/gbd.json'
df = pd.read_json(path)

this is the error I am getting.


ValueError                                Traceback (most recent call last)
<ipython-input-11-3e269770844d> in <module>()
      1 path = '/content/drive/MyDrive/gbd.json'
----> 2 df = pd.read_json(path)

6 frames
/usr/local/lib/python3.7/dist-packages/pandas/io/json/_json.py in _parse_no_numpy(self)
   1138         if orient == "columns":
   1139             self.obj = DataFrame(
-> 1140                 loads(json, precise_float=self.precise_float), dtype=None
   1141             )
   1142         elif orient == "split":

ValueError: Expected object or value

I have tried all the following solutions

data= pd.read_json('Data.json', lines=True)

data= pd.read_json('Data.json', lines=True, orient='records')

data= pd.read_json('Data.json', orient=str)

this is the link to the json file
https://ccewuksprdoneregsadata1.blob.core.windows.net/data/json/publicextract.charity.zip
I want to create a dataframe from the json file

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

i was able to make a DataFrame with a small extract of your file and the problem was that there is a small unvisible group of char before the beginning of the file, which somehow blocks it. It wouldn’t be visible to all editors and it was s pure luck that I tested it with different editors. This char looks something like , try to open it with different editors and to delete it and it will work.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading