code: def main(opts):
      dir = opts["<dir>"]
      if not dir:
          dir = "test-logs"
      dir = Path(dir)
      print("scanning directory", dir)
  
      res = []
      for f in dir.glob("log-*/emissions.csv"):
          print("found emissions in", f.parent.name)
          key = f.parent.name[4:]
          data = pd.read_csv(f)
          data["key"] = key
          res.append(data)
  
      df = pd.concat(res, ignore_index=True)
      print(
          "total power usage: {:.4f} kWh".format(
              df["energy_consumed"].sum()
          )
      )
      print(
          "total emissions: {:.4f} kgCO2".format(df["emissions"].sum())
      )
      df.to_csv(dir / "emissions.csv", index=False)
  
imports: from pathlib import Path
  import pandas
  from docopt import docopt
label_desc: Use image node_id 1 for calling a global function with example usage: main(opts) without return types