conference_footprint

compute the CO2 footprint of an academic conference
git clone https://a3nm.net/git/conference_footprint/
Log | Files | Refs

transform.py (508B)


      1 #!/usr/bin/env python3
      2 
      3 import json
      4 import sys
      5 
      6 year = int(sys.argv[1])
      7 people = int(sys.argv[2])
      8 total = int(sys.argv[3])
      9 location = sys.argv[4]
     10 
     11 trips = []
     12 for l in sys.stdin.readlines():
     13     f = l.strip().split(',')
     14     mode = f[0]
     15     dist = f[1]
     16     trip = {
     17         "mode": mode,
     18         "dist": int(dist)
     19     }
     20     trips.append(trip)
     21 
     22 edition_data = {
     23     "year": year,
     24     "location": location,
     25     "participants": people,
     26     "emissions": total,
     27     "trips": trips
     28 }
     29 
     30 print(json.dumps(edition_data))