AI Skill Report Card
Validating CSV Batch Files
Markdown--- name: validating-csv-batch-files description: Validates and corrects fixed-format CSV batch report files (with header/trailer control rows and data rows) against a filename and content specification tied to a report date. Automatically fixes formatting issues (case, decimal precision, extension) while flagging data discrepancies (dates, sequence numbers, record counts, charge totals) to the user for confirmation before applying changes. Use when a user provides a CSV batch file and a report date and asks to check, validate, or reconcile the file against format specifications. ---
Quick Start14 / 15
Given [[Input File]] and [[Report Date]]:
- Parse filename → extract date and sequence number.
- Parse file → split into first row (header), last row (trailer), and data rows (everything in between).
- Run all format checks (Workflow Step 2) — auto-fix silently, log each fix.
- Run all data checks (Workflow Step 3) — for each discrepancy, pause and ask user to choose among proposed options or enter free text.
- Apply user's chosen value to the working copy (never touch original input).
- Repeat validation from Step 2 until zero issues remain.
- Rename file to match
[[Report Date]]with.CSVextension, present final download link.
Recommendation▾
Add an example of an auto-corrected ambiguous time field to show the escalation path in action
Workflow15 / 15
Maintain two things in memory throughout the session:
- original: the untouched original filename + file contents (never overwritten).
- working copy: the current amended version, updated only after user confirms a value.
Progress:
- [ ] Step 1: Parse filename and extract report date + sequence number
- [ ] Step 2: Run format checks (auto-correct, no user input needed)
- [ ] Step 3: Run data checks (ask user for each discrepancy)
- [ ] Step 4: Apply confirmed corrections to working copy
- [ ] Step 5: Re-run Steps 2–3 on working copy (repeat until clean)
- [ ] Step 6: Rename/finalize file, present download link
Step 1: Filename Parsing
- Extract embedded date and sequence number from filename per spec pattern.
- Compare filename date to
[[Report Date]]. - Confirm extension is exactly
.CSV(uppercase), not.csvor other case variants.
Step 2: Format Checks (auto-correct, no confirmation needed)
These are pure formatting/syntax issues — fix silently and log what was changed:
- File extension → force to
.CSV. - Filename date mismatch vs
[[Report Date]]→ do not auto-rename yet; hold until all data issues resolved (renaming is final step). - Service ID casing → uppercase every character.
- Total charge amount format → exactly 2 decimal places.
- File creation/closure time → must be valid
HHmmSS(00-23 / 00-59 / 00-59); if malformed but unambiguous (e.g., missing leading zero), auto-correct; if ambiguous, escalate to Step 3 as a data issue.
Step 3: Data Checks (always ask user before changing)
For each issue found, present:
Issue: <description>
Field: <row/column reference>
Current value: <value>
Proposed value: <system-computed correct value>
Options:
[1] Accept proposed value: <value>
[2] Enter custom value: ____
Checks to run, in order:
First row (header):
- File creation date ==
[[Report Date]]== filename date. - File creation time is valid
HHmmSS. - Sequence number in header == sequence number in filename.
Data rows:
- Exactly 22 fields per row (flag rows with more/fewer; ask user how to split/pad/trim).
- Record dates fall in the month prior to
[[Report Date]]'s month. - Record type
O: start date == 1st of month; end date == blank. - Record type
R: start date == 1st of month; end date == last day of that month.
Last row (trailer):
- Sequence number == filename sequence number.
- File closure date ==
[[Report Date]]== filename date. - File closure time is valid
HHmmSSand >= file creation time from first row. - Record count == actual count of data rows.
- Total charge amount == sum of all data row charges, formatted to 2 decimals.
Step 4–5: Apply and Reiterate
- After every user decision, update the working copy only (never the original).
- Re-run the full check pipeline (Steps 2–3) against the updated working copy.
- Continue until a full pass produces zero format and zero data issues.
Step 6: Finalize
- Rename working copy file to the spec-compliant filename (matching
[[Report Date]], correct sequence number,.CSVextension). - Present a download link and a short summary of all changes made (auto-fixes + user-confirmed corrections).
Recommendation▾
Include a malformed field-count example (row with wrong number of fields) since it's mentioned but never demonstrated
Examples16 / 20
Example 1: Service ID casing (auto-fix, no user prompt)
Input: data row contains SVCID: "abc123xz"
Output: Silently corrected to "ABC123XZ"; logged as a format fix in the final summary.
Example 2: Record count mismatch (ask user)
Input: Trailer row states RECORD_COUNT=150, but actual data rows = 148.
Output:
Issue: Record count mismatch
Field: Last row, record count
Current value: 150
Proposed value: 148
Options:
[1] Accept proposed value: 148
[2] Enter custom value: ____
Example 3: Record type O with non-blank end date
Input: Row has TYPE=O, START=2024-03-01, END=2024-03-31
Output:
Issue: Record type O requires blank end date
Field: Data row (line 45), end date
Current value: 2024-03-31
Proposed value: (blank)
Options:
[1] Accept proposed value: (blank)
[2] Enter custom value: ____
Recommendation▾
Consider adding a brief 'spec format' reference or sample filename pattern since the workflow assumes an external spec not shown in the skill itself
Best Practices
- Always keep the original file/contents in memory (or a snapshot) so undo/reference is possible without re-requesting from user.
- Batch related issues from the same row together when presenting to the user to minimize back-and-forth.
- Always show both the current (bad) value and the computed proposed value — never ask the user to guess.
- Treat filename renaming as the very last action, only once file content is fully validated.
- Clearly distinguish in your logs/output between "auto-fixed format issue" and "user-confirmed data correction."
Common Pitfalls
- Do not auto-correct data values (dates, record counts, charge totals, sequence numbers) without explicit user confirmation — only formatting (case, decimals, extension) can be auto-fixed.
- Do not rename the file or alter the report date until all data rows and control rows pass validation.
- Do not lose the original input — every amendment must be applied to a working copy, never in place on the original.
- Do not stop after one pass — always reiterate validation after each correction since fixes can reveal or resolve dependent issues (e.g., record count changes after row corrections).
- Do not miscount "data rows" — first and last row are control rows and must be excluded from that term.