I have a JSON file (file1.json
) that looks this:
{"key":"value","key":"value"}
{"key":"value","key":"value"}
I cant read in this file with pd.read_json('filepath/file1.json')
I get error:
ValueError: Expected object or value
I tried opening the file and reading in the with open
like so:
with open('~/filepath/file1.json') as f:
json_data = pd.json_normalize(json.loads(f.read()),encodings='utf-8-sig')
But I get error:
json.decoder.JSONDecodeError: Unexpected UTF-8 BOM (decode using utf-8-sig): line 1 column 1 (char 0)
However, when I read remove all rows except the top 2 from the file and add a comma like so:
{"key":"value","key":"value"},
{"key":"value","key":"value"}
I can read in the file as is with pd.read_json()
.
How can I read in the file with non comma separated file dict objects per line?
Thanks in advance.