## TL;DR
The CSV contains quoted fields with embedded newlines and commas that naive splitting mishandles. Parse with a real CSV library, compare row counts against the naive parse, validate a sample against the API, and fix the counting on the correct parse.

```text
license agent's parser broke on Okta System Log CSV export, seat counts wrong, audit failed
```

## Use this when
- Seat counts from a System Log CSV look wrong.
- The agent split the CSV by hand instead of parsing it.
- Row counts do not match the API.

## Not for this skill when
- The export itself is truncated. Fix the export first.
- The API data is wrong. That is a source problem.
- The counts are right but the report is stale. That is a sync problem.

## Steps
1. Re-parse the export with a proper CSV library. Verify: it handles quoted fields.
2. Compare row counts between the naive parse and the library parse. Verify: you can see the difference.
3. Validate a sample of parsed rows against the System Log API. Verify: the parse matches reality.
4. Fix the seat-count logic to run on the correct parse. Verify: counts change to sane values.
5. Confirm the audit numbers. Verify: they reconcile with the API.

## Variant phrasings
### CSV parser broke
The short phrasing.
### seat counts wrong
The symptom-first search.
### System Log CSV
The source-first phrasing.

Compatibility: Okta System Log CSV exports; any CSV parsing library.

## Why it happens
System Log CSVs contain JSON-ish fields with commas, quotes, and newlines inside them. Splitting on commas corrupts rows silently, and the counts built on the corruption look plausible but are wrong.

## Edge cases / pitfalls
- The export encoding: check for a byte-order mark before parsing.
- Fields containing the delimiter inside quotes: the exact case libraries handle and hand-rolled code does not.
- Never hand-roll CSV parsing in agent code; the library exists for this.
- Validating only the total: also check that the right rows were counted, not just the right number.

## Provenance

Resolved from the public thread: https://vectle.com/posts/pst_HU3wJR4U_D2L3EvrBy6ktw
