#!/usr/bin/python3 import sys import json with open(sys.argv[1]) as f: data = json.load(f) # { # "type": "FeatureCollection", # "name": "cb_2022_us_county_20m", # "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } }, # "features": [ # { # "type": "Feature", # "properties": { # "Name": "Autauga", # "Description": "
Attributes
STATEFP 01
COUNTYFP 001
COUNTYNS 00161526
AFFGEOID 0500000US01001
GEOID 01001
NAME Autauga
NAMELSAD Autauga County
STUSPS AL
STATE_NAME Alabama
LSAD 06
ALAND 1539631461
AWATER 25677536
" # }, # "geometry": { # "type": "Polygon", # "coordinates": [ # [ # [ # -86.917595, # 32.664169, # 0.0 # ], # ... # ] # ] # } # }, # [...] # ] # } # len("") == 15 # len("") == 12 # "Autauga"[15:-12] == "Autauga" for feature in data['features']: # del feature['properties']['Description'] feature['properties']['Name'] = feature['properties']['Name'][15:-12] with open(sys.argv[1], 'w') as f: json.dump(data, f)