Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

importing json file from github into python. Getting Error: JSONDecodeError: Expecting value: line 7 column 1 (char 6)

Tags:

python

json

sql

Here is my code:

import re, json, requests

url = 'https://github.com/caminofinancial/data-eng-take-home/blob/master/prequalresult.json'

resp = requests.get(url)
resp_parsed = re.sub(r'^jsonp\d+\(|\)\s+$', '', resp.text)
data = json.loads(resp_parsed)
print(data)

And I Got the error : JSONDecodeError: Expecting value: line 7 column 1 (char 6). Can someone check it and solve the issue?

like image 910
L.s Avatar asked Oct 24 '25 05:10

L.s


1 Answers

Use the raw GitHub URL when you need to access the file directly. You can get it by clicking the 'Raw' button on the page.

 url = 'https://raw.githubusercontent.com/caminofinancial/data-eng-take-home/master/prequalresult.json'
 resp = requests.get(url)
 data = json.loads(resp.text)
 print(data)
like image 85
Abhishek Menon Avatar answered Oct 25 '25 20:10

Abhishek Menon



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!