I have a function that generates a report from Excel file. For now, it work like:
import json
def get_dic_from_two_lists(keys, values):
return { keys[i] : values[i] for i in range(len(keys)) }
def report(items):
for i in range(items):
dict_keys = ['name', 'age']
dict_values = ['n', 'a']
data = get_dic_from_two_lists(dict_keys, dict_values)
report = json.dumps(data)
print(report)
report(5)
Where items is number of reports to generate.
It works good, but I need to append results into a list and separate JSON objects with a comma and, moreover, write everything to a file. Any good way to do it? append() function just doesn't seem to work out.
Thanks!