don't open it in r+ mode. first open it for reading. After you process data, open it again for writing and dump data.
There are some redundant steps in what you do, e.g. no need to delete the coordinates node first
There are some redundant steps in what you do, e.g. no need to delete the coordinates node first
import json json_file = 'features.json' with open(json_file) as f: json_data = json.load(f) for feature in json_data['features']: coordinates = feature['geometry']['coordinates'][0].split(',') feature['geometry']['coordinates'] = [float(coord.strip()) for coord in coordinates] with open(json_file, 'w') as f: json.dump(json_data, f, indent=4)
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs