First draft on a script to gather some general stats, mostly totals by tags and decades. Diary has no movie data other than that so I can add country/genre data.
**TODO**: Save to file (preferably markdown), add totals besides movie titles, specify tag groups (?).
**How to use**: Export your data^[https://letterboxd.com/settings/data/]. Edit diary.csv: keep first line, delete all entries you don't want. Run script :)
General:
```python
import csv
from pprint import pprint
tags = {}
decades = {}
with open('{}.csv'.format('diary'), newline='') as csvfile:
freader = csv.DictReader(csvfile, delimiter=',', quotechar='"')
for itm in freader:
ftags = itm["Tags"].split(', ')
for tag in ftags:
existing = tags.get(tag, [])
existing.append(itm["Name"])
tags[tag] = existing
decade = itm["Year"]
decade = decade[:-1] + '0'
edecades = decades.get(decade, [])
edecades.append(itm["Name"])
decades[decade] = edecades
pprint(tags)
pprint(decades)
```
Aggregated:
```python
import csv
from pprint import pprint
tags = {}
decades = {}
with open('{}.csv'.format('diary'), newline='') as csvfile:
freader = csv.DictReader(csvfile, delimiter=',', quotechar='"')
for itm in freader:
ftags = itm["Tags"].split(', ')
for tag in ftags:
prefix = 'other'
actual_tag = tag
if (tag.find(': ') > 0):
# print(tag)
prefix, actual_tag = tag.split(': ')
if (prefix not in tags):
tags[prefix] = {}
if (actual_tag not in tags[prefix]):
tags[prefix][actual_tag] = 0
tags[prefix][actual_tag] += 1
decade = itm["Year"]
decade = decade[:-1] + '0'
if (decade not in decades):
decades[decade] = 0
decades[decade] += 1
pprint(tags)
pprint(decades)
```