Add book id to entries
This commit is contained in:
parent
21d9b5b802
commit
b88721b4f8
File diff suppressed because one or more lines are too long
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user