I have a json file that I need to modify. I've successfully done that, but when I push it to the json file, it appears at the bottom as if appended. I'm using seek(0) but that doesn't seem to work. Any suggestions?
f = open("C:\last_esri.json", "r")
data = json.load(f)
f.close()
for i in(data['fields']):
for item in i:
if i[item] == 'esriFieldTypeOID':
i.update({'type' :'oid'})
elif i[item] == 'esriFieldTypeString':
i.update({'type' :'string'})
elif i[item] == 'esriFieldTypeInteger':
i.update({'type' :'integer'})
elif i[item] == 'esriFieldTypeDouble':
i.update({'type' :'double'})
elif i[item] == 'esriFieldTypeDate':
i.update({'type' :'date'})
f = open("C:\data\last_esri.json", 'w+')
f.seek(0)
f.write(json.dumps(data, indent=1))
f.close()