download.py 776 B

1234567891011121314151617181920212223242526
  1. import tqdm
  2. import os
  3. import pathlib
  4. from unfccc_di_api import UNFCCCApiReader
  5. ROOT_DIR = pathlib.Path(os.path.abspath(os.curdir)) # This is your Project Root
  6. def main():
  7. r = UNFCCCApiReader()
  8. for party in tqdm.tqdm(r.parties["code"], desc="parties"):
  9. if party != "AUS":
  10. continue
  11. df = r.query(party_code=party, progress=False)
  12. annexI = party in r.annex_one_reader.parties["code"].values
  13. subdir = "annexI" if annexI else "non-annexI"
  14. directory = ROOT_DIR / "data" / subdir
  15. directory.mkdir(parents=True, exist_ok=True)
  16. df.to_csv(directory / f"{party}.csv.gz", compression="gzip")
  17. df.to_parquet(directory / f"{party}.parquet", compression="brotli")
  18. if __name__ == "__main__":
  19. main()