Skip to content

Commit

Permalink
create automatic excel file creation
Browse files Browse the repository at this point in the history
  • Loading branch information
Gordon Blackadder committed Aug 9, 2024
1 parent 7857924 commit a29291c
Show file tree
Hide file tree
Showing 12 changed files with 20 additions and 1 deletion.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@ View documentation - https://worldbank.github.io/metadata-schemas/

To update the pydantic schemas so that they match the json schemas run

`python pydantic_schemas\\utils\\generate_pydantic_schemas.py`
`python pydantic_schemas\\generators\\generate_pydantic_schemas.py`

Then to update the Excel sheets run

`python pydantic_schemas\\generators\\generate_excel_files.py`
Binary file removed excel_sheets/Document_metadata.xlsx
Binary file not shown.
Binary file removed excel_sheets/Script_metadata.xlsx
Binary file not shown.
Binary file removed excel_sheets/Series_metadata.xlsx
Binary file not shown.
Binary file removed excel_sheets/Survey_microdata_metadata.xlsx
Binary file not shown.
Binary file removed excel_sheets/Table_metadata.xlsx
Binary file not shown.
Binary file removed excel_sheets/Timeseries_DB_metadata.xlsx
Binary file not shown.
Binary file removed excel_sheets/Timeseries_metadata.xlsx
Binary file not shown.
Binary file removed excel_sheets/Video_metadata.xlsx
Binary file not shown.
3 changes: 3 additions & 0 deletions pydantic_schemas/excel_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ class ExcelInterface:
"video": excel_single_sheet_to_pydantic, # one sheet
}

def get_metadata_types(self):
return list(self._TYPE_TO_READER.keys())

@staticmethod
def _merge_dicts(base, update):
if len(update) == 0:
Expand Down
12 changes: 12 additions & 0 deletions pydantic_schemas/generators/generate_excel_files.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import os

from pydantic_schemas.excel_interface import ExcelInterface

ei = ExcelInterface()

for metadata_type in ei.get_metadata_types():
filename = f"excel_sheets/{metadata_type.capitalize()}_metadata.xlsx"
print(f"Writing {metadata_type} outline to {filename}")
if os.path.exists(filename):
os.remove(filename)
ei.write_outline_metadata_to_excel(metadata_type=metadata_type, filename=filename)

0 comments on commit a29291c

Please sign in to comment.