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
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.
The file is not well formatted. Try:
with open('publicextract.charity.json', encoding='utf-8-sig') as fp:
data = json.loads(''.join(line.strip() for line in fp))
df = pd.json_normalize(data)
Output:
date_of_extract organisation_number registered_charity_number linked_charity_number charity_name ... cio_is_dissolved date_cio_dissolution_notice charity_activities charity_gift_aid charity_has_land
0 2022-02-02T00:00:00 1 200027 1 POTTERNE MISSION ROOM AND TRUST ... None None None None None
1 2022-02-02T00:00:00 2 200027 2 HITCHAM FREE CHURCH ... None None None None None
2 2022-02-02T00:00:00 3 200028 1 TOWN LANDS CHARITY FOR THE POOR ... None None None None None
3 2022-02-02T00:00:00 4 200028 2 TOWN LANDS CHARITY FOR THE CHURCH ... None None None None None
4 2022-02-02T00:00:00 5 200034 1 CLOPHILL RELIEF IN NEED CHARITY ... None None None None None
... ... ... ... ... ... ... ... ... ... ... ...
376732 2022-02-02T00:00:00 5193574 1197688 0 FEN DRAYTON PRIMARY SCHOOL PTA ... False None None None None
376733 2022-02-02T00:00:00 5193708 1197741 0 BOLSOVER C OF E JUNIOR SCHOOL FROG ... False None None None None
376734 2022-02-02T00:00:00 5193765 1197681 0 ST MICHAEL'S RC PRIMARY PTA ... False None None None None
376735 2022-02-02T00:00:00 5193830 1197732 0 THE LIGHTHOUSE, DARWEN ... False None None None None
376736 2022-02-02T00:00:00 5193998 1197750 0 THE PENDLE FOUNDATION ... False None None None None
[376737 rows x 34 columns]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.