1796/extracting-data-from-a-json-file-in-python
import json from pprint import pprint data = json.load(open('data.json')) pprint(data)
This will store the JSON data in the dictionary named data.
pprint() simply prints your data in a neat manner, preserving the indentation
I am new to geojson. Can someone please let me know how to extract co-ordinates from geojson file to python. i tried this and similar codes but received errors.
import geojson with open("pvt.dat_191022_174643.geojson") as f: gj = geojson.load(f) print gj for feature in gj: a= feature.properties.geometry.type print a print feature.geometry.coordinates
Error: Traceback (most recent call last): File "read_geojson.py", line 8, in a= feature.properties.geometry.type AttributeError: 'str' object has no attribute 'properties'
Try replacing the 6th line with the following:
a = feature.geometry.type
Instead of
a= feature.properties.geometry.type
You could try using the AST module. ...READ MORE
Hi, nice question. So what I daily use ...READ MORE
Hi, there is a very simple solution ...READ MORE
Hi, good question. Let us first assume that ...READ MORE
You can also use the random library's ...READ MORE
Syntax : list. count(value) Code: colors = ['red', 'green', ...READ MORE
can you give an example using a ...READ MORE
You can simply the built-in function in ...READ MORE
file = open('text.txt', 'w+) READ MORE
Here's a generator that yields the chunks ...READ MORE
OR
Already have an account? Sign in.