Files
troupe-standup/wizard-work/ledger/make_csv.py
T

15 lines
595 B
Python

import json, csv
raw = json.load(open('/root/troupe-standup/wizard-work/ledger/raw_crypto.json'))
cols = ['rank', 'name', 'symbol', 'current_price', 'market_cap',
'market_cap_change_24h_pct', 'total_volume', 'circulating_supply',
'ath', 'ath_date', 'atl', 'atl_date', 'last_updated']
with open('/root/troupe-standup/wizard-work/ledger/crypto_top10.csv', 'w', newline='') as f:
w = csv.DictWriter(f, fieldnames=cols)
w.writeheader()
for i, r in enumerate(raw, start=1):
w.writerow({**{c: r.get(c) for c in cols}, 'rank': i})
print('wrote crypto_top10.csv')