Skip to content

Commit

Permalink
Mauritania has only group level data
Browse files Browse the repository at this point in the history
  • Loading branch information
mcarans committed Feb 17, 2025
1 parent 6c1a4bb commit f94a8eb
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 57 deletions.
112 changes: 60 additions & 52 deletions ipc.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,34 +433,38 @@ def generate_dataset_and_showcase(self, folder, output):
)

area_rows = output["area_rows_latest"]
filename = f"ipc_{countryiso3lower}_area_long_latest.csv"
resourcedata = {
"name": filename,
"description": "Latest IPC area data in long form with HXL tags",
}
success, results = dataset.generate_resource_from_iterable(
list(area_rows[0].keys()),
area_rows,
self.configuration["long_hxltags"],
folder,
filename,
resourcedata,
)
if area_rows:
filename = f"ipc_{countryiso3lower}_area_long_latest.csv"
resourcedata = {
"name": filename,
"description": "Latest IPC area data in long form with HXL tags",
}
success, results = dataset.generate_resource_from_iterable(
list(area_rows[0].keys()),
area_rows,
self.configuration["long_hxltags"],
folder,
filename,
resourcedata,
)
elif not group_rows:
logger.error(f"{countryiso3} has no latest subnational data!")

area_rows_wide = output["area_rows_wide_latest"]
filename = f"ipc_{countryiso3lower}_area_wide_latest.csv"
resourcedata = {
"name": filename,
"description": "Latest IPC area data in wide form with HXL tags",
}
success, results = dataset.generate_resource_from_iterable(
list(area_rows_wide[0].keys()),
area_rows_wide,
self.configuration["wide_hxltags"],
folder,
filename,
resourcedata,
)
if area_rows_wide:
filename = f"ipc_{countryiso3lower}_area_wide_latest.csv"
resourcedata = {
"name": filename,
"description": "Latest IPC area data in wide form with HXL tags",
}
success, results = dataset.generate_resource_from_iterable(
list(area_rows_wide[0].keys()),
area_rows_wide,
self.configuration["wide_hxltags"],
folder,
filename,
resourcedata,
)

country_rows_wide = output["country_rows_wide"]
if len(country_rows_wide) == 1:
Expand Down Expand Up @@ -528,33 +532,37 @@ def generate_dataset_and_showcase(self, folder, output):
)

area_rows = output["area_rows"]
filename = f"ipc_{countryiso3lower}_area_long.csv"
resourcedata = {
"name": filename,
"description": "All IPC area data in long form with HXL tags",
}
success, results = dataset.generate_resource_from_iterable(
list(area_rows[0].keys()),
area_rows,
self.configuration["long_hxltags"],
folder,
filename,
resourcedata,
)
if area_rows:
filename = f"ipc_{countryiso3lower}_area_long.csv"
resourcedata = {
"name": filename,
"description": "All IPC area data in long form with HXL tags",
}
success, results = dataset.generate_resource_from_iterable(
list(area_rows[0].keys()),
area_rows,
self.configuration["long_hxltags"],
folder,
filename,
resourcedata,
)
elif not group_rows:
logger.error(f"{countryiso3} has no subnational data!")

area_rows_wide = output["area_rows_wide"]
filename = f"ipc_{countryiso3lower}_area_wide.csv"
resourcedata = {
"name": filename,
"description": "All IPC area data in wide form with HXL tags",
}
success, results = dataset.generate_resource_from_iterable(
list(area_rows_wide[0].keys()),
area_rows_wide,
self.configuration["wide_hxltags"],
folder,
filename,
resourcedata,
)
if area_rows_wide:
filename = f"ipc_{countryiso3lower}_area_wide.csv"
resourcedata = {
"name": filename,
"description": "All IPC area data in wide form with HXL tags",
}
success, results = dataset.generate_resource_from_iterable(
list(area_rows_wide[0].keys()),
area_rows_wide,
self.configuration["wide_hxltags"],
folder,
filename,
resourcedata,
)

return dataset, showcase
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
hdx-python-api==6.3.5
hdx-python-api==6.3.8
python-slugify==8.0.4
8 changes: 4 additions & 4 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ def create_dataset(
dataset, showcase = ipc.generate_dataset_and_showcase(
folder, output
)
create_dataset(
dataset,
showcase,
)
# create_dataset(
# dataset,
# showcase,
# )
if country_data_updated:
output = ipc.get_all_data()
dataset, showcase = ipc.generate_dataset_and_showcase(
Expand Down

0 comments on commit f94a8eb

Please sign in to comment.