Framework for Python

Data

data_read()

Read data by catalog name or file path.

Files found by catalog name are integrity-checked: Framework records the file's SHA-256 in framework.db the first time and compares it on every later read. A changed locked file raises IntegrityError. A changed unlocked file issues a DataChangedWarning.

Usage

data_read(
    path: str,
    delim: str | None = None,
    keep_attributes: bool = False,
    **kwargs: Any,
) -> pd.DataFrame

Arguments

Name Type Default Description
path required str

A catalog name such as "inputs.raw.survey", or a file path.

delim str | None None

Delimiter for delimited text: comma, tab, semicolon, or space. Default: the catalog's delimiter, then the file extension.

keep_attributes bool False

Keep value labels from Stata and SPSS files as categories. By default the stored codes are returned, as in R.

**kwargs Any

Passed to the pandas (or pyreadstat) reader.

Raises

  • DataNotFoundError: The name is not in the catalog, or the file is missing.
  • UnsupportedFormatError: The file is an .rds file or another format Python cannot read.
  • IntegrityError: A locked file changed since its hash was recorded.