Add book id to entries

This commit is contained in:
Alfred Melch 2019-12-22 12:14:49 +01:00
parent 21d9b5b802
commit b88721b4f8
2 changed files with 7 additions and 3 deletions

File diff suppressed because one or more lines are too long

View File

@ -12,11 +12,15 @@ new_data = list()
stats_for = ['language', 'rights', 'subject']
stats = {key: defaultdict(int) for key in stats_for}
for entry in data.values():
for book_id, entry in data.items():
# strip formaturi from entry
new_entry = {key: entry[key] for key in entry if key != 'formaturi'}
new_entry['id'] = book_id
new_data.append(new_entry)
# add stats
for stat_key in stats_for:
for value in entry[stat_key]:
stats[stat_key][value] += 1
new_data.append({key: entry[key] for key in entry if key != 'formaturi'})
for stat in stats.keys():
with open('data/stats_' + stat + '.json', 'w') as f: