caoscrawler.converters.spss module#

Converter for SAV files (stored by SPSS).

Configuration#

SPSS interpretation can be configured via a file. This TOML file has the following sections:

[labels]#

Each entry is a list of strings with the possible values for the label. The entry’s key shall be used as RecordType name.

Example

[labels]

Hometown = ["Moscow", "Rome", "Paris", "Lisbon"]
class caoscrawler.converters.spss.SPSSConverter(definition: dict, name: str, converter_registry: dict)#

Bases: TableConverter

Converter for SAV files (stored by SPSS).

create_children(values: GeneralStore, element: StructureElement) list#
caoscrawler.converters.spss.read_column_types(savfile: str | None = None, meta: Any | None = None) dict[str, str]#

Read SAV file and return the column types.

Optionally, take data from a previours reading.

Parameters:
  • savfile (Optional[str]) – The SAV file to read.

  • meta (Optional) – The meta data result from pyreadstat.read_sav(…).

Returns:

out – The column names and types.

Return type:

dict[str, str]

caoscrawler.converters.spss.spss_to_datamodel_main()#

The main function of this script.

caoscrawler.converters.spss.spss_to_yaml(savfile: str, yamlfile: str, cfood: str | None = None, conf: str | dict | None = None, strict: str = 'NONE') None#

Parse the *.sav and create basic datamodel in yamlfile.

Parameters:
  • cfood (str, optional) – If given, also create a cfood skeleton.

  • conf (Union[str, dict], optional) – If given, a dict with with more options, or the location of a corresponding config.toml file.

  • strict (str, default="NONE") – If NONE, nothing special happens if the configuration is not sufficient. If WARN, the function emits a warning. If FULL, all labels must be given in the configuration. Missing labels will lead to a help message and an exception will be raised.