The second utility step inserts territory data into the utility.territory database table. Unlike the observation utility steps, this step calls the manage process file directly rather than through a job file — there is only one file to run.

Prerequisite

Run Translate general utilities first to generate manage_territory.json.

Notebook cell

In load_ai4sh_utility_data.ipynb, the Manage general utilities cell runs:

process_file = 'import_data/utility/general/manage_process/manage_territory.json'

structured_process_D, scheme_params_D = Initiate_process(notebook_path, scheme_file, process_file)

if structured_process_D is not None:
    Run_process(structured_process_D, scheme_params_D)

Note that this cell passes a process_file path directly, not a job_file. This bypasses the pilot file mechanism and executes the single manage file immediately.

Manage process file

Path: ./ai4sh/import_data/utility/general/manage_process/manage_territory.json

The file contains one JSON object per territory row from territory.xlsx. Each object follows this structure:

{
  "process": [
    {
      "root_process_id": "import_tabular_data",
      "process": "manage_territory",
      "delete": false,
      "overwrite": false,
      "parameters": {
        "name": "sweden",
        "display_name": "Sweden",
        "iso_code_a2": "se",
        "iso_code_a2_ext": "se"
      }
    },
    {
      "root_process_id": "import_tabular_data",
      "process": "manage_territory",
      "delete": false,
      "overwrite": false,
      "parameters": {
        "name": "denmark",
        "display_name": "Denmark",
        "iso_code_a2": "dk",
        "iso_code_a2_ext": "dk"
      }
    }
  ]
}

The full file contains one entry per ISO country/territory. The file is generated by the translate step and should not be edited manually — re-run the translate cell if you need to add territories.

Flags

Flag Default Effect
delete false If true, removes the record instead of inserting
overwrite false If true, updates an existing record with matching primary key

Next step

Proceed to Translate observation utilities to convert the observation utility catalogues.

Updated: