Skip to content

Commit

Permalink
Add short documentation on utility function
Browse files Browse the repository at this point in the history
  • Loading branch information
dc-almeida committed Nov 26, 2024
1 parent 1db5a56 commit b257fc1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
15 changes: 15 additions & 0 deletions docs/updating-nuts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Updating the NUTS source file

EUROSTAT occasionally updates the current NUTS classification spreadsheet. These updates might be minor and not encompass changing region names or codes, but knowing they take place, it is important to ensure the package accesses the most up-to-date version of the data.

To this end, a weekly GitHub action compares pysquirrel's copy of the file and the version hosted in the EUROSTAT website with a hash check. The workflow fails if hashes differ.

In such a case, using a local installation of pysquirrel, and with the newest version of the spreadsheet downloaded:

```python
from pysquirrel.core import nuts_to_yaml

nuts_to_yaml("path/to/latest_nuts.xlsx", "path/to/output")
```

The function will parse the XLSX file and output the two corresponding YAML files (for NUTS regions and Statistical Regions). YAML files allow for easy tracking of changes in GitHub commits.
4 changes: 2 additions & 2 deletions pysquirrel/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ def flatten(lst):
yield i


def nuts_to_yaml(path: str, output_dir: str):
def nuts_to_yaml(file_path: str, output_dir: str):
"""Converts a NUTS .xlsx source file to YAML files."""

workbook = load_workbook(path, read_only=True, data_only=True)
workbook = load_workbook(file_path, read_only=True, data_only=True)

for sheet, file in {
"NUTS2024": "NUTS2021-2024.yaml",
Expand Down

0 comments on commit b257fc1

Please sign in to comment.