read_data_set.py 882 B

123456789101112131415161718192021222324252627282930313233
  1. """Read selected domains and versions."""
  2. from pathlib import Path
  3. import click
  4. from faostat_data_primap.helper.definitions import domains_and_releases_to_read
  5. from faostat_data_primap.helper.paths import (
  6. downloaded_data_path,
  7. extracted_data_path,
  8. )
  9. from faostat_data_primap.read import (
  10. read_data,
  11. )
  12. @click.command()
  13. @click.option("--run_id", default="2024", help="Configuration to run")
  14. @click.option("--save_path", default=None, help="Where to save data in root directory.")
  15. def run(run_id, save_path):
  16. """Prepare and run read data function"""
  17. if not save_path:
  18. save_path = extracted_data_path
  19. else:
  20. save_path = Path(save_path)
  21. read_data(
  22. read_path=downloaded_data_path,
  23. domains_and_releases_to_read=domains_and_releases_to_read[run_id],
  24. save_path=save_path,
  25. )
  26. if __name__ == "__main__":
  27. run()