简体   繁体   English

将 json 文件从 github 导入 python。出现错误:JSONDecodeError:期望值:第 7 行第 1 列(字符 6)

[英]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.

相关问题 一直有效的 Python 文件突然得到 json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) - Python file that has always worked suddenly getting json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) 在python中加载有效的json文件会引发错误JSONDecodeError:预期值:第1行第1列(字符0) - loading valid json file in python throws error JSONDecodeError: Expecting value: line 1 column 1 (char 0) 从列表中循环时出现 python 错误 json.decoder.JSONDecodeError:预期值:第 1 行第 1 列(字符 0) - python error while looping from a list json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) json.decoder.JSONDecodeError:期望值:第 1 行第 1 列(字符 0)python - json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) python Python:json.decoder.JSONDecodeError:期望值:第 1 行第 1 列(字符 0) - Python: json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) json.decoder.JSONDecodeError:期望值:第2行第1列(char 1)错误 - json.decoder.JSONDecodeError: Expecting value: line 2 column 1 (char 1) error 错误:json.decoder.JSONDecodeError:期望值:第 1 行第 1 列(字符 0) - ERROR: json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) JSONDecodeError:期望值:第 1 行第 1 列(字符 0),我收到此错误 - JSONDecodeError: Expecting value: line 1 column 1 (char 0), I am getting this error Python Error: json.decoder.JSONDecodeError: Expecting value: line 2 column 1 (char 2) when json.loads a valid json file - Python Error: json.decoder.JSONDecodeError: Expecting value: line 2 column 1 (char 2) when json.loads a valid json file yFinance 的 JSON 解码错误 [JSONDecodeError: Expecting value: line 1 column 1 (char 0)] - JSON Decode Error with yFinance [JSONDecodeError: Expecting value: line 1 column 1 (char 0)]
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM