I created a new JSON document to upload data to a couchdb instance. The code works. The problem is that the data written by the Python script is displayed in a single line by text editors. Is there a way to add linebreaks? Here is the code:
newdict = {}
outputdict = {}
docs_list = []
for number, item in enumerate(data['docs']):
# pprint (item)
# print item['key'][4]
newdict["key1"] = item['key'][0]
newdict["yek1"] = item['key'][1]
newdict["key2"] = item['key'][2]
newdict["yek2"] = item['key'][3]
newdict["key3"] = item['key'][4]
newdict["yek3"] = item['value']['lat']
newdict["key4"] = item['value']['long']
docs_list.append(newdict)
outputdict["docs"] = docs_list
outputdict = json.dumps(outputdict)
pprint (outputdict)
with open("filename.json",'w') as f:
f.write(outputdict)