【问题标题】:Convert Json File to data Frame将 Json 文件转换为数据帧
【发布时间】:2020-10-30 21:27:36
【问题描述】:

我正在尝试读取我保存的 json 文件 https://www.mahindrausa.com/js/locations.js

import json
data=json.load(open('Mahindra.json'))

但是我收到了这个错误。 从 None 提高 JSONDecodeError("Expecting value", s, err.value) JSONDecodeError: 期望值

需要帮助。

【问题讨论】:

  • 到目前为止你尝试了什么?
  • 欢迎来到 Stack Overflow!您似乎在要求某人为您编写一些代码。 Stack Overflow 是一个问答网站,而不是代码编写服务。请see here学习如何写出有效的问题。
  • 我正在尝试使用 json.load(open(filename)) 读取文件,但是它抛出了一个错误.. raise JSONDecodeError("Expecting value", s, err.value) from None JSONDecodeError:期望值

标签: python json html-parsing


【解决方案1】:

您不能只获取原始数据。您必须对其进行修改,使其看起来像这样。

[  {
"type": "Feature",
"geometry": {
  "type": "Point",
  "coordinates": [
    52.743356,
    -111.546907
  ]
},
"properties": {
  "dealerName": "Smiths Equipment Sales (Smiths Hauling)",
  "address": "HWY 13 - 5018 Alberta Avenue",
  "city": "Lougheed",
  "state": "AB",
  "zip": "T0B 2V0",
  "country": "Canada",
  "website": "http://smithsequipsales.com/",
  "phone": "780-386-3842",
  "dealerCode": "SMI06",
  "tractor": true,
  "utv": false,
  "hp": false
}  },  {
"type": "Feature",
"geometry": {
  "type": "Point",
  "coordinates": [36.16876,-84.07945]
},
"properties": {
  "dealerName": " Tommy's Motorsports",
  "address": "2401 N Charles G Seivers Blvd",
  "city": "Clinton",
  "state": "TN",
  "statename": "United States",
  "zip": "37716",
  "phone": "865-494-6500",
  "website": "https://www.tommysmotorsports.com/",
  "dealerCode": "TOM08",
  "tractor": true,
  "utv": false,
  "hp": false
  }
}
]

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-14
    • 2018-06-15
    • 2020-07-31
    • 2023-03-04
    • 2020-09-06
    • 2018-08-19
    相关资源
    最近更新 更多