Capstone: from a messy CSV to a summary you can trust
Puts the track together: parse CSV with quotes, validate every field with its line number and aggregate per model.
Combines the 7 exercises of the Data and text track. It unlocks when you finish them, but you can try it now.
RUNS is a speed-test log as people really keep it: quoted notes, a blank line, typos and \r\n line ends. Write summarize(csv) that returns { valid, errors, byModel }.
- Split into lines (
\nor\r\n). Line 1 is the header. Skip blank lines, but count them for numbering. Fields may be quoted with commas inside and""as a quote; there will be no line breaks inside a field. - Validate each row:
modelnot empty,datea realYYYY-MM-DDdate andtokens_per_seca number above 0. For every field that fails, add{ line, field }toerrors, in column order. A row with any error does not count. validis the number of good rows.byModelis a list of{ model, runs, avgTps }sorted bymodel, with the average rounded to one decimal. Use that key order.
Challenges 0/5
- Counts 5 valid rows (quotes do not break the row)
- Reports each error with its line and field
- Aggregates per model: runs and the average to one decimal
- A row with three problems gives three errors, in column order
- Copes with empty text and a header alone
function summarize(csv) {
// 1. split into lines (\n or \r\n); line 1 is the header; skip blank lines but keep counting them
// 2. split each line into fields: a comma inside "quotes" does not split, and "" is a quote
// 3. check model (not empty), date (a real YYYY-MM-DD) and tokens_per_sec (a number above 0)
// 4. average tokens_per_sec per model over the valid rows, one decimal, sorted by model
return { valid: 0, errors: [], byModel: [] };
}
console.log(summarize(RUNS));Tab indents, Ctrl+Z undoes. To leave the editor with the keyboard: Esc, then Tab.
Why this matters
No real file arrives clean. This project puts together what you do before any data touches a model: read the CSV without breaking the quotes, validate every field and say which line fails, and aggregate only what passed validation. The line number is what turns "there are errors" into something the person who exported the file can fix. A summary built this way can be defended; one made by a model over the raw file cannot. How to check the end result is in AI evaluations: test your RAG before going live.
Go deeper: the RFC 4180 reference →
This in production, with your data? Let's talk for 15 minutes →