nicer car count script

pull/22979/head
Adeeb Shihadeh 3 years ago
parent 5f731ee914
commit 1b800f4075
  1. 9
      scripts/count_cars.py

@ -1,10 +1,15 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import os import os
from collections import Counter
from pprint import pprint
from common.basedir import BASEDIR from common.basedir import BASEDIR
with open(os.path.join(BASEDIR, "docs/CARS.md")) as f: with open(os.path.join(BASEDIR, "docs/CARS.md")) as f:
lines = f.readlines() lines = f.readlines()
cars = [l for l in lines if l.strip().startswith("|") and l.strip().endswith("|") and cars = [l for l in lines if l.strip().startswith("|") and l.strip().endswith("|") and
"Make" not in l and any(c.isalpha() for c in l)] "Make" not in l and any(c.isalpha() for c in l)]
print(''.join(cars))
print(len(cars)) make_count = Counter([l.split('|')[1].split('|')[0].strip() for l in cars])
print("\n", "*"*20, len(cars), "total", "*"*20, "\n")
pprint(make_count)

Loading…
Cancel
Save