{"id":23847,"library":"hdx-python-utilities","title":"HDX Python Utilities","description":"Supporting utilities for the HDX Python ecosystem, including streaming tabular data (CSV/JSON/Excel), date/time handling, URL manipulation, file I/O, and general helper functions. Current version 4.0.8, requires Python >=3.10, follows weekly release cadence.","status":"active","version":"4.0.8","language":"python","source_language":"en","source_url":"https://github.com/OCHA-DAP/hdx-python-utilities","tags":["hdx","humanitarian","data","tabular","csv","excel","json"],"install":[{"cmd":"pip install hdx-python-utilities","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Used for country-level operations","package":"hdx-python-country","optional":true},{"reason":"Used for HDX API interactions","package":"hdx-python-api","optional":true},{"reason":"Used for tabular data formatting","package":"tablib","optional":true}],"imports":[{"note":"save_iterable_to_csv is in file_handler, not top-level utilities","wrong":"from hdx.utilities import save_iterable_to_csv","symbol":"save_iterable_to_csv","correct":"from hdx.utilities.file_handler import save_iterable_to_csv"},{"note":"load_csv is in loader module","wrong":"from hdx.utilities import load_csv","symbol":"load_csv","correct":"from hdx.utilities.loader import load_csv"},{"note":"Moved to url module in 4.0.4","wrong":"from hdx.utilities.loader import get_filename_from_url","symbol":"get_filename_from_url","correct":"from hdx.utilities.url import get_filename_from_url"},{"note":"Moved to url module in 4.0.4","wrong":"from hdx.utilities.loader import get_filename_extension_from_url","symbol":"get_filename_extension_from_url","correct":"from hdx.utilities.url import get_filename_extension_from_url"},{"note":"Moved to url module in 4.0.4","wrong":"from hdx.utilities.loader import get_path_for_url","symbol":"get_path_for_url","correct":"from hdx.utilities.url import get_path_for_url"},{"note":"Moved to url module in 4.0.4","wrong":"from hdx.utilities.loader import get_url_for_get","symbol":"get_url_for_get","correct":"from hdx.utilities.url import get_url_for_get"},{"note":"Moved to url module in 4.0.4","wrong":"from hdx.utilities.loader import get_url_params_for_post","symbol":"get_url_params_for_post","correct":"from hdx.utilities.url import get_url_params_for_post"},{"note":"smart_split is in text module (added in 4.0.7)","wrong":"from hdx.utilities.loader import smart_split","symbol":"smart_split","correct":"from hdx.utilities.text import smart_split"}],"quickstart":{"code":"from hdx.utilities.loader import load_csv\nfrom hdx.utilities.file_handler import save_iterable_to_csv\n\n# Load a CSV file\nfilepath = 'data.csv'\ndata = load_csv(filepath)\n\n# Save an iterable (list of dicts) to CSV\nrecords = [{'name': 'Alice', 'age': 30}, {'name': 'Bob', 'age': 25}]\nsave_iterable_to_csv(records, 'output.csv', headers=['name', 'age'])\n\nprint('Done')","lang":"python","description":"Load CSV and save iterable as CSV. Requires Python >=3.10."},"warnings":[{"fix":"Upgrade to Python 3.10 or later, or pin to hdx-python-utilities<4.0.0 if you must use an older Python.","message":"Python 3.10+ required starting from version 4.0.0. Older Python versions (3.6, 3.8, 3.9) are no longer supported.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Change imports from 'hdx.utilities.loader' to 'hdx.utilities.url' for these functions.","message":"URL-related functions (get_filename_from_url, get_filename_extension_from_url, get_path_for_url, get_url_for_get, get_url_params_for_post) moved from loader module to url module in 4.0.4. Old imports will break.","severity":"breaking","affected_versions":">=4.0.4"},{"fix":"Always provide explicit headers list when saving tabular data to ensure correct column order and completeness.","message":"save_iterable expects headers to be list of strings ordered as desired. For a list of dicts, if headers are not specified, they are inferred from the first dict's keys, which may not preserve order or include all keys.","severity":"gotcha","affected_versions":"all"},{"fix":"Update code to handle the new behavior where None is no longer returned unexpectedly. Test your row functions.","message":"Functions that returned None in edge cases (e.g., row_function returning None) now handle that edge case properly. Old code relying on None may break.","severity":"deprecated","affected_versions":">=4.0.8"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use: from hdx.utilities.url import get_filename_from_url","cause":"Function moved to hdx.utilities.url in 4.0.4.","error":"ImportError: cannot import name 'get_filename_from_url' from 'hdx.utilities.loader'"},{"fix":"Install with: pip install hdx-python-utilities","cause":"Package not installed or installed under a different name.","error":"ModuleNotFoundError: No module named 'hdx.utilities'"},{"fix":"Check the documentation for your version. In recent versions, use 'headers' parameter. For older versions, use 'fieldnames' or omit.","cause":"Parameter name changed in an older version; 'headers' might be 'fieldnames' or require a different signature.","error":"TypeError: save_iterable_to_csv() got an unexpected keyword argument 'headers'"},{"fix":"Use: from hdx.utilities.loader import load_csv (not import hdx.utilities)","cause":"The utilities module might not have submodules imported automatically; need explicit import.","error":"AttributeError: module 'hdx.utilities' has no attribute 'loader'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}