load: load datagrams and tables

Code author: Ueli Sauter, Peter Kraus

The function dgpost.utils.load.load() processes the below specification in order to load the datagram json file:

pydantic model dgbowl_schemas.dgpost.recipe.Load

Select external files (NetCDF or json datagrams, pkl tables) to load.

Show JSON schema
{
   "title": "Load",
   "description": "Select external files (``NetCDF`` or ``json`` datagrams, ``pkl`` tables) to load.",
   "type": "object",
   "properties": {
      "as": {
         "title": "As",
         "type": "string"
      },
      "path": {
         "title": "Path",
         "type": "string"
      },
      "type": {
         "default": "datagram",
         "enum": [
            "netcdf",
            "datagram",
            "table"
         ],
         "title": "Type",
         "type": "string"
      },
      "check": {
         "anyOf": [
            {
               "type": "boolean"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Check"
      }
   },
   "additionalProperties": false,
   "required": [
      "as",
      "path"
   ]
}

Config:
  • extra: str = forbid

  • populate_by_name: bool = True

Validators:
field as_: str [Required] (alias 'as')

Name under which the loaded object will be stored in memory.

field path: str [Required]

Path to the file containing the object to be loaded.

field type: Literal['netcdf', 'datagram', 'table'] = 'datagram'

Type of the loaded object. Can be either a NetCDF file created e.g. using yadg~5.0, a datagram file in JSON format created using yadg~4.0, or a table stored in a pkl file as created by Pandas.

Validated by:
field check: bool | None = None

Deprecated since version 2.1: The check attribute of Load has been deprecated. The passed value is currently ignored, however it will cause an error in future versions of Recipe.

Validated by:
validator check_is_deprecated  »  check
validator lowercase_type  »  type

Note

The key as is not processed by load(), it should be used by its caller to store the returned datagram or pd.DataFrame into the correct variable.

dgpost.utils.load.load(path: str, check: bool | None = None, type: str = 'netcdf') dict | DataFrame