Dataset quality and validation
Turn field rules, reports, source comparisons and failure review into a practical quality process.
In this guide
1. Define what a good record means
Write down the meaning and expected source of each field. Required fields detect missing values, but a nonempty value can still be the wrong value. A valid-looking title selected from a neighboring column is a quality failure even if the job reports no rejection.
Decide whether your downstream consumer needs every source record or can tolerate partial coverage. Define the review threshold before examining the results.
2. Use field validation deliberately
| Field rule | What it checks | What it does not prove |
|---|---|---|
| required | A usable value is present after extraction and defaults. | The selected value belongs to the intended entity. |
| data_type | The selected string can be interpreted as the requested type. | That a number is within a domain-specific range. |
| min_length | The extracted value meets a minimum length. | That a long value is complete, accurate or free of boilerplate. |
| normalize_whitespace | Whitespace is normalized when enabled. | That the result is a lossless copy of source markup. |
| default | A fallback can be supplied for absent data. | That a missing identifier or source fact has been recovered. |
3. Keep fields inside one row
Use row_selector for repeated records. Field selectors are evaluated within each selected container so that a missing field in one row cannot pull a value from a neighboring row.
One record per page can omit row_selector. In both cases compare selected values with representative source pages. Scoped extraction prevents one class of misalignment; it does not validate business meaning.
{
"row_selector": "article.product",
"fields": [
{ "name": "sku", "selector": "article.product", "extract_type": "attr:data-sku", "required": true },
{ "name": "name", "selector": "h2", "required": true },
{ "name": "price", "selector": ".price", "extract_type": "price", "data_type": "float", "required": true }
],
"dedup_fields": ["sku"]
}4. Choose record identity
URL deduplication and record deduplication are different. The first skips repeated source URLs; the second skips valid records whose selected field values have already been observed in the job.
An empty dedup_fields list compares all extracted fields. Specifying a stable identifier compares only those named fields. Exact deduplication does not merge records or find semantically similar entities.
For a price history, a product ID alone would collapse later observations within the same job. Model the identity as the observation you intend to retain, and include any required timestamp or snapshot identity in your downstream design.
5. Interpret completion and errors
| Signal | Interpretation | Action |
|---|---|---|
| complete = true | The input reached its end. | Still inspect failures and rejected records. |
| cancelled = true | Cancellation was requested during this invocation. | Wait for the worker to stop, then resume with a new job handle. |
| pages_failed > 0 | Some sources did not produce a successfully processed page. | Inspect the corresponding error shards. |
| records_rejected > 0 | Some rows failed extraction or validation. | Compare those rows with the source. |
| duplicate_urls or duplicate_records > 0 | Exact duplicate checks skipped inputs or records. | Confirm the result matches your intended identity rule. |
6. Make acceptance a separate decision
The following strict policy is an example. A research project may choose a different documented threshold, but should never treat an exception-free run as proof that all values are correct.
def accept_for_review(report):
if report["cancelled"] or not report["complete"]:
return False
if report["pages_failed"] or report["records_rejected"]:
return False
return True
if not accept_for_review(report):
raise RuntimeError("Inspect the report and error shards")
print("Ready for source comparison")7. Compare output to the source
Choose sample rows before reviewing results. Compare identifiers, titles, classifications and any critical field to the source snapshot. Include edge cases, not only the easiest examples.
Use an independent parser or a manual transcription where possible. Record the number checked, the comparison procedure and mismatches. If the source changes between collection and comparison, preserve the snapshot or explain the timing difference.
The recorded PEP validation compared the full directory’s IDs, titles and classifications. Its document-body comparison covered PEP 1 only. That scope is narrower than a claim that all extracted documents are correct.
8. Describe missing data
Report the intended source population, pages attempted, successfully processed pages, accepted rows, rejected rows and the sampling method. One successful index page may contain many records; page counts and record counts are not interchangeable.
A finished resume does not revisit committed page failures. Once you have corrected the problem, create a new URL file and job directory for the retry or refresh, and keep its relationship to the earlier snapshot explicit.
9. Detect and respond to source changes
Track missing-field and rejected-record counts over time, then manually inspect values that remain nonempty. A selector can silently match the wrong element after a redesign.
DatasetJob uses explicit field selectors and does not apply the separate Dataset builder’s heuristic auto-match. Update the rule and start a new job directory when the configuration changes.
10. Quality review checklist
- Save the job configuration, source list and collector version.
- Inspect report counters and retain the error shards.
- Confirm the intended identity and understand duplicate counts.
- Compare representative fields against a dated source snapshot.
- Document missing sources, sampling choices and transformations.
- Review source permissions and the intended use separately from technical validation.