download.py 728 B

123456789101112131415161718192021222324
  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. df = r.query(party_code=party, progress=False)
  10. annexI = party in r.annex_one_reader.parties["code"].values
  11. subdir = "annexI" if annexI else "non-annexI"
  12. directory = ROOT_DIR / "data" / subdir
  13. directory.mkdir(parents=True, exist_ok=True)
  14. df.to_csv(directory / f"{party}.csv.gz", compression="gzip")
  15. df.to_parquet(directory / f"{party}.parquet", compression="brotli")
  16. if __name__ == "__main__":
  17. main()