CSV Data Check
<!-- OB-S:ecOkU0Y9B9AxgJeer1mSOA -->Produce a reproducible CSV quality report and explain findings in the user's language. Use the bundled checker for counts rather than estimating from a preview. Runtime and tests require Python 3.10+ and its standard library only.
Run the Audit
Identify the local input path and any user-specified encoding, delimiter, or row limit. The first nonblank CSV record is the header. Do not guess a schema, delimiter, or encoding from a few rows. Default settings are comma-separated CSV and UTF-8 with optional BOM.
From this Skill's directory:
python3 scripts/check_csv.py /path/to/input.csv
When invoked from elsewhere, resolve scripts/check_csv.py relative to this SKILL.md and use the script's full path. Quote paths containing spaces.
For a known tab-separated file with a specified encoding:
python3 scripts/check_csv.py /path/to/input.tsv --delimiter '\t' --encoding gb18030
Limit a large-file audit only when a partial result is appropriate:
python3 scripts/check_csv.py /path/to/input.csv --max-rows 100000 --max-examples 3
JSON goes to stdout. To create a report file, add --output report.json. The destination must not already exist; the checker never overwrites it or repairs the input. Missing files, invalid encodings, malformed quoted CSV, and I/O failures produce a stderr error and exit 2, not a fabricated success report.
Interpret the Report
- coverage.rows_checked counts nonblank data records, excluding the header. coverage.blank_records_skipped includes blank records before the header.
- coverage.complete is true only after EOF was observed. Reaching --max-rows always marks coverage incomplete, even if that limit might match the file's length. Do not describe a limited scan as a full-file audit.
- columns uses one-based indices and retains original header names. Empty or repeated names are findings, not silently renamed columns.
- A missing cell is absent from a short record or contains only whitespace. NULL, NA, and similar literal strings are not guessed to be missing values. missing_rate uses all checked data records as its denominator. It is null when there are no data records.
- malformed_row_count counts records with fewer or more fields than the header. Missing trailing fields contribute to missing-cell counts; extra fields do not become unnamed report columns.
- duplicate_row_count counts occurrences after the first matching parsed record, including structurally malformed records. Quoting differences that parse to the same fields match. Nonempty whitespace and case are preserved.
- examples contains bounded issue locations, never raw cell values. record is one-based among checked nonblank data records. line_start and line_end are physical file lines; quoted multiline fields can span several lines.
- status is clean, issues_found, or incomplete. An empty dataset is a finding. These statuses describe these checks only, not schema or business validity.
The default exit code 0 means a report was produced, including reports with findings. With --strict, exit 0 requires a complete audit without findings; findings or incomplete coverage return 1. Usage/read/write failures return 2.
Explain the checked scope, then give counts and relevant column indices. Distinguish confirmed findings from possible causes. Recommend targeted next steps, but only change the data when the user separately requests a repair.
Privacy and Resource Behavior
The checker makes no network requests and leaves the input unchanged. Reports include the source path, header names, counts, and record locations, but not cell values. Review paths and headers before sharing a report publicly.
Rows are streamed; exact duplicate detection uses a SQLite index in a private temporary directory that is removed on normal completion or a handled error. The index temporarily contains parsed cell values. Disk use grows with distinct records; memory depends on column count and the largest record. A hard process kill can leave temporary files, and disk exhaustion is an audit error. Python's CSV parser field-size limit applies. Do not weaken parser limits without a user-approved need.
Demonstration and Tests
assets/example.csv contains synthetic records only:
python3 scripts/check_csv.py assets/example.csv
python3 -B -m unittest discover -s tests -v
The example yields 6 checked records, 1 duplicate occurrence, 2 malformed records, and 4 missing cells. A natural-language request for this Skill is: "Check this CSV before import. Report missing cells, duplicate records, and row-width problems without changing the file."

Scan to join WeChat group