[英]importing json file from github into python. Getting Error: JSONDecodeError: Expecting value: line 7 column 1 (char 6)
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).我得到了错误:JSONDecodeError:期望值:第 7 行第 1 列(字符 6)。 Can someone check it and solve the issue?
有人可以检查并解决问题吗?
Use the raw GitHub URL when you need to access the file directly.当您需要直接访问文件时,使用原始 GitHub URL。 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)
from pyspark import SparkFiles
zip_url = "https://raw.githubusercontent.com/spark-examples/spark-scala-examples/master/src/main/resources/zipcodes.json"
spark.sparkContext.addFile(zip_url)
zip_df = spark.read.json("file://" +SparkFiles.get("zipcodes.json"))
#click on raw and then copy url #click on raw然后复制url
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.