# read_results()

Read the results of a validation from a file written by [write_results()](../reference/write_results.md#pointblank.write_results).

Usage

[Source](https://github.com/posit-dev/pointblank/blob/main/pointblank/validate.py#L1759-L1853)

``` python
read_results(filepath)
```

This gives a [Validate](../reference/Validate.md#pointblank.Validate) object with the results of the run in the file: its steps, their results, and the metadata of the run. All of the reports work on it, as on the original validation: the validation report (with `get_tabular_report()` or by printing the object), [get_json_report()](../reference/Validate.get_json_report.md#pointblank.Validate.get_json_report), [get_dataframe_report()](../reference/Validate.get_dataframe_report.md#pointblank.Validate.get_dataframe_report), the verdict methods (`all_passed()`, `assert_below_threshold()`, …), the counts and fractions by step (`n_passed()`, …), and `get_health_score()`. It can also be one of the validations in a [MultiValidate](../reference/MultiValidate.md#pointblank.MultiValidate) object.

A results file holds no table, no data extracts, and no validation plan that could be run, so the methods that need them ([interrogate()](../reference/Validate.interrogate.md#pointblank.Validate.interrogate), [get_data_extracts()](../reference/Validate.get_data_extracts.md#pointblank.Validate.get_data_extracts), [get_sundered_data()](../reference/Validate.get_sundered_data.md#pointblank.Validate.get_sundered_data), [get_row_flags()](../reference/Validate.get_row_flags.md#pointblank.Validate.get_row_flags), [get_step_report()](../reference/Validate.get_step_report.md#pointblank.Validate.get_step_report), `to_code()`, `to_yaml()`, and [add_steps()](../reference/Validate.add_steps.md#pointblank.Validate.add_steps)) raise an error. The `pre=` functions, expressions, and other values that a results file keeps only as a description come back as objects that print as that description (e.g., the source code of a function), for the reports.

Reading a results file runs no code, so it's safe to read one from any source.

## Parameters

`filepath: str | Path`  
The path of the results file. The `.json` extension is added if the path has no extension.

## Returns

`Validate`  
A validation with the results of the run in the file.

## Examples

Let's write the results of a validation to a file, and read them back:

``` python
import pointblank as pb
import os
import tempfile

validation = (
    pb.Validate(
        data=pb.load_dataset("small_table"),
        tbl_name="small_table",
        label="Nightly check",
        thresholds=(0.1, 0.25),
    )
    .col_vals_gt(columns="d", value=1000)
    .col_vals_le(columns="c", value=pb.col("d"))
    .col_vals_not_null(columns="c")
    .interrogate()
)

results_dir = tempfile.mkdtemp()
pb.write_results(validation, "nightly", path=results_dir)

restored = pb.read_results(os.path.join(results_dir, "nightly.json"))

restored
```

[TABLE]

The report is the same as the report of the original validation, except that there are no data extracts to download (the `EXT` column has a dash for every step). The verdict methods work as on the original, too:

``` python
restored.all_passed(), restored.n_failed(i=1, scalar=True)
```

    (False, 6)

The first step has 6 failing test units, so not all of the steps passed.

## See Also

[write_results()](../reference/write_results.md#pointblank.write_results)  
Write the results of an interrogated validation to a JSON file.

[from_files()](../reference/MultiValidate.from_files.md#pointblank.MultiValidate.from_files)  
Read several results files into one [MultiValidate](../reference/MultiValidate.md#pointblank.MultiValidate) object.

[read_file()](../reference/read_file.md#pointblank.read_file)  
Load a whole validation object saved with [write_file()](../reference/write_file.md#pointblank.write_file).
