Tested prompt · Coding
Parse CSV with quoted fields: every AI model's reply, tested
We sent this hard coding prompt to all 20 models in llmwise, the same way the app sends a message, and checked every reply the same way. Here's each one as it came, with whether it passed, what it cost and how long it took.
Based on 20 of our test runs on , through OpenRouter with the app's own prompt and settings. Updated .
Short answer
19 of 20 models passed this coding prompt's check (tests); Claude Haiku 4.5 didn't. The cheapest reply that passed was GLM 5.3 Flash's, at $0.00026; the fastest, GLM 5.3's in 2.6 s. The dearest reply, Claude Fable 5.1's, cost 267 times as much ($0.0697).
The prompt, as sent, and its check
Checked by tests, the same way for every model.
Parse CSV with quoted fields (hard)
Write a JavaScript function parseCsv(text) that parses CSV text into an array of rows, each an array of strings. - Fields are separated by commas, and rows by \n or \r\n. - A field may be wrapped in double quotes. Inside quotes, commas and line breaks are part of the field, and "" stands for one double quote. - A quote inside a field that doesn't start with one is an ordinary character. - A line break at the very end of the text doesn't start a new row, and an empty string gives []. Reply with the whole function in one ```javascript code block: plain JavaScript for Node.js 22, no imports, no TypeScript.
The reply's parseCsv runs against these 8 tests; it passes when all of them do.
parseCsv("a,b,c\n1,2,3") // → [["a", "b", "c"], ["1", "2", "3"]]
parseCsv('"x, y",z') // → [["x, y", "z"]]
parseCsv('"say ""hi""",2') // → [["say \"hi\"", "2"]]
parseCsv('"line1\nline2",end\r\nnext,row\r\n') // → [["line1\nline2", "end"], ["next", "row"]]
parseCsv("a,,c\n,\n") // → [["a", "", "c"], ["", ""]]
parseCsv("") // → []
parseCsv('he said "no",x') // → [["he said \"no\"", "x"]]
parseCsv('a,"b"\n"",c') // → [["a", "b"], ["", "c"]]Exactly what this prompt's replies are checked against, with every other prompt of our test runs.
Every model's result
All 20 models on this prompt, in catalog order.
| Model | Result | Cost | Time | Reply |
|---|---|---|---|---|
| Claude Fable 5.1Anthropic | Passed: All 8 tests passed. | $0.0697 | 14.3 s | 1,229 tokens |
| Claude Opus 5.5Anthropic | Passed: All 8 tests passed. | $0.0273 | 11.9 s | 563 tokens |
| Claude Sonnet 5.5Anthropic | Passed: All 8 tests passed. | $0.0114 | 5.3 s | 978 tokens |
| Claude Sonnet 5Anthropic | Passed: All 8 tests passed. | $0.0187 | 15.8 s | 463 tokens |
| Claude Haiku 5.5Anthropic | Passed: All 8 tests passed. | $0.00081 | 8.1 s | 516 tokens |
| Claude Haiku 4.5Anthropic | Failed: 5 of 8 tests passed. First failure: parseCsv('"line1\nline2",end\r\nnext,row\r\n'): Expected values to be strictly deep-equal: | $0.0033 | 3.5 s | 559 tokens |
| GPT-6 AstraOpenAI | Passed: All 8 tests passed. | $0.0314 | 9.1 s | 313 tokens |
| GPT-6.1 SolOpenAI | Passed: All 8 tests passed. | $0.0038 | 8.4 s | 321 tokens |
| GPT-6 SolOpenAI | Passed: All 8 tests passed. | $0.0081 | 8.9 s | 349 tokens |
| GPT-6 LunaOpenAI | Passed: All 8 tests passed. | $0.00043 | 7.2 s | 315 tokens |
| Gemini 4 ArgonGoogle | Passed: All 8 tests passed. | $0.0025 | 5.0 s | 359 tokens |
| Gemini 3.1 Pro (preview)Google | Passed: All 8 tests passed. | $0.0291 | 20.6 s | 462 tokens |
| Gemini 3.8 FlashGoogle | Passed: All 8 tests passed. | $0.0022 | 5.0 s | 480 tokens |
| DeepSeek V4.1 FlashDeepSeek | Passed: All 8 tests passed. | $0.0042 | 9.1 s | 399 tokens |
| DeepSeek V4 ProDeepSeek | Passed: All 8 tests passed. | $0.0357 | 122.3 s | 325 tokens |
| Grok 4.7xAI | Passed: All 8 tests passed. | $0.0364 | 72.2 s | 402 tokens |
| Kimi K3Moonshot | Passed: All 8 tests passed. | $0.0069 | 4.1 s | 360 tokens |
| GLM 5.3Z.ai | Passed: All 8 tests passed. | $0.0024 | 2.6 s | 456 tokens |
| GLM 5.3 FlashZ.ai | Passed: All 8 tests passed. | $0.00026 | 8.4 s | 426 tokens |
| Mistral Large 4Mistral | Passed: All 8 tests passed. | $0.0118 | 57.3 s | 697 tokens |
Cost: what OpenRouter charged us for the reply. Time: from sending to the whole reply. Reply: its length in tokens, thinking not counted. In llmwise you pay per message, not per token: each of these replies counted as one message on Pro.
Every reply
The reply that failed first, then the ones that passed, from the cheapest up.
Claude Haiku 4.5
Failed: 5 of 8 tests passed. First failure: parseCsv('"line1\nline2",end\r\nnext,row\r\n'): Expected values to be strictly deep-equal:
```javascript function parseCsv(text) { if (text === "") return []; const rows = []; let currentRow = []; let currentField = ""; let inQuotes = false; let i = 0; while (i < text.length) { const char = text[i]; if (inQuotes) { if (char === '"') { if (i + 1 < text.length && text[i + 1] === '"') { // "" inside quotes means a literal quote currentField += '"'; i += 2; } else { // End of quoted field inQuotes = false; i++; } } else { // Any character (including comma, newline) inside quotes is part of the field currentField += char; i++; } } else { if (char === '"') { // Start of quoted field inQuotes = true; i++; } else if (char === ",") { // Field separator currentRow.push(currentField); currentField = ""; i++; } else if (char === "\r") { // Handle \r\n or \r currentRow.push(currentField); currentField = ""; if (i + 1 < text.length && text[i + 1] === "\n") { i += 2; } else { i++; } // Only add row if there's more content after the line break if (i < text.length) { rows.push(currentRow); currentRow = []; } } else if (char === "\n") { // Row separator currentRow.push(currentField); currentField = ""; i++; // Only add row if there's more content after the line break if (i < text.length) { rows.push(currentRow); currentRow = []; } } else { // Ordinary character currentField += char; i++; } } } // Add the last field and row currentRow.push(currentField); rows.push(currentRow); return rows; } ```518 tokens in, 559 out · 3.5 s · $0.0033 · 1 message on Pro · answered by anthropic/claude-haiku-4.5 via Amazon Bedrock ·
GLM 5.3 Flash
Passed: All 8 tests passed.
```javascript function parseCsv(text) { if (text === "") return []; const rows = []; let row = []; let field = ""; let inQuotes = false; let i = 0; // Track whether the field started with a quote let fieldQuoted = false; function endField() { row.push(field); field = ""; fieldQuoted = false; } function endRow() { endField(); rows.push(row); row = []; } while (i < text.length) { const ch = text[i]; if (inQuotes) { if (ch === '"') { if (text[i + 1] === '"') { field += '"'; i += 2; } else { inQuotes = false; i++; } } else { field += ch; i++; } continue; } if (field === "" && !fieldQuoted && ch === '"') { fieldQuoted = true; inQuotes = true; i++; continue; } if (ch === ",") { endField(); i++; continue; } if (ch === "\r" || ch === "\n") { // handle \r\n as one line break if (ch === "\r" && text[i + 1] === "\n") i++; // a line break at the very end of the text doesn't start a new row if (i + 1 >= text.length || (ch === "\r" && i + 2 >= text.length)) { i++; continue; } endRow(); i++; continue; } field += ch; i++; } // final field/row if anything pending (a field was started) if (field !== "" || fieldQuoted || row.length > 0) { endRow(); } return rows; } ```495 tokens in, 434 out (8 of them reasoning) · 8.4 s · $0.0003 · 1 message on Pro · answered by z-ai/glm-5.3-flash via AtlasCloud ·
GPT-6 Luna
Passed: All 8 tests passed.
```javascript function parseCsv(text) { if (text === "") return []; const rows = []; let row = []; let field = ""; let inQuotes = false; let endedWithRowBreak = false; for (let i = 0; i < text.length; i++) { const char = text[i]; if (inQuotes) { if (char === '"') { if (text[i + 1] === '"') { field += '"'; i++; } else { inQuotes = false; } } else { field += char; } endedWithRowBreak = false; continue; } if (char === '"' && field === "") { inQuotes = true; endedWithRowBreak = false; } else if (char === ",") { row.push(field); field = ""; endedWithRowBreak = false; } else if (char === "\n" || (char === "\r" && text[i + 1] === "\n")) { row.push(field); rows.push(row); row = []; field = ""; if (char === "\r") i++; endedWithRowBreak = true; } else { field += char; endedWithRowBreak = false; } } if (!endedWithRowBreak) { row.push(field); rows.push(row); } return rows; } ```481 tokens in, 762 out (447 of them reasoning) · 7.2 s · $0.0004 · 1 message on Pro · answered by openai/gpt-6-luna via OpenAI ·
Claude Haiku 5.5
Passed: All 8 tests passed.
```javascript function parseCsv(text) { const rows = []; if (text === '') return rows; let row = []; let field = ''; let inQuotes = false; let fieldStart = true; // true only at the very beginning of a field let i = 0; const n = text.length; while (i < n) { const c = text[i]; if (inQuotes) { if (c === '"') { if (text[i + 1] === '"') { field += '"'; i += 2; } else { inQuotes = false; i++; } } else { field += c; i++; } continue; } if (c === '"' && fieldStart) { inQuotes = true; fieldStart = false; i++; continue; } if (c === ',') { row.push(field); field = ''; fieldStart = true; i++; continue; } if (c === '\n' || c === '\r') { row.push(field); rows.push(row); row = []; field = ''; fieldStart = true; if (c === '\r' && text[i + 1] === '\n') i += 2; else i++; continue; } field += c; fieldStart = false; i++; } // Flush the last row unless the text ended with a line break if (row.length > 0 || field !== '' || !fieldStart) { row.push(field); rows.push(row); } return rows; } ```670 tokens in, 1,464 out (948 of them reasoning) · 8.1 s · $0.0008 · 1 message on Pro · answered by anthropic/claude-haiku-5.5 via Anthropic ·
Gemini 3.8 Flash
Passed: All 8 tests passed.
```javascript function parseCsv(text) { if (text === '') return []; // Remove a single trailing newline if present if (text.endsWith('\r\n')) { text = text.slice(0, -2); } else if (text.endsWith('\n')) { text = text.slice(0, -1); } if (text === '') return []; const rows = []; let currentRow = []; let currentField = ''; let inQuotes = false; let isStartOfField = true; for (let i = 0; i < text.length; i++) { const char = text[i]; if (inQuotes) { if (char === '"') { if (text[i + 1] === '"') { currentField += '"'; i++; // skip escaped quote } else { inQuotes = false; } } else { currentField += char; } } else { if (isStartOfField && char === '"') { inQuotes = true; isStartOfField = false; } else if (char === ',') { currentRow.push(currentField); currentField = ''; isStartOfField = true; } else if (char === '\r' && text[i + 1] === '\n') { currentRow.push(currentField); rows.push(currentRow); currentRow = []; currentField = ''; isStartOfField = true; i++; // skip '\n' } else if (char === '\n') { currentRow.push(currentField); rows.push(currentRow); currentRow = []; currentField = ''; isStartOfField = true; } else { currentField += char; isStartOfField = false; } } } currentRow.push(currentField); rows.push(currentRow); return rows; } ```515 tokens in, 480 out · 5.0 s · $0.0022 · 1 message on Pro · answered by google/gemini-3.8-flash via Google ·
GLM 5.3
Passed: All 8 tests passed.
```javascript function parseCsv(text) { if (text === '') return []; const rows = []; let row = []; let field = ''; let inQuotes = false; let i = 0; const n = text.length; while (i < n) { const c = text[i]; if (inQuotes) { if (c === '"') { if (text[i + 1] === '"') { field += '"'; i += 2; } else { inQuotes = false; i++; } } else { field += c; i++; } continue; } if (c === '"' && field === '' && (i === 0 || /[\n\r,]/.test(text[i - 1]))) { inQuotes = true; i++; } else if (c === ',') { row.push(field); field = ''; i++; } else if (c === '\r' && text[i + 1] === '\n') { row.push(field); rows.push(row); row = []; field = ''; i += 2; } else if (c === '\n' || c === '\r') { row.push(field); rows.push(row); row = []; field = ''; i++; } else { field += c; i++; } } // Only emit a final row if there's a pending field/row (avoids trailing newline creating empty row) if (field !== '' || row.length > 0) { row.push(field); rows.push(row); } return rows; } ``` Notes on behavior: - A quote only starts a quoted field at the beginning of a field (start of input, after a comma, or after a line break), per your third rule; otherwise `"` is literal. - `""` inside quotes becomes a single `"`. - Embedded `\n`/`\r\n` inside quotes stays in the field; a trailing newline at the end of input doesn't create an empty final row; `''` returns `[]`.518 tokens in, 463 out (7 of them reasoning) · 2.6 s · $0.0024 · 1 message on Pro · answered by z-ai/glm-5.3 via Wafer ·
Gemini 4 Argon
Passed: All 8 tests passed.
```javascript function parseCsv(text) { if (text === "") return []; const rows = []; let row = []; let field = ""; let inQuotes = false; let fieldStart = true; for (let i = 0; i < text.length; i++) { const ch = text[i]; if (inQuotes) { if (ch === '"') { if (text[i + 1] === '"') { field += '"'; i++; } else { inQuotes = false; } } else { field += ch; } continue; } if (fieldStart && ch === '"') { inQuotes = true; fieldStart = false; } else if (ch === ",") { row.push(field); field = ""; fieldStart = true; } else if (ch === "\n" || (ch === "\r" && text[i + 1] === "\n")) { if (ch === "\r") i++; row.push(field); rows.push(row); row = []; field = ""; fieldStart = true; if (i === text.length - 1) return rows; } else { field += ch; fieldStart = false; } } row.push(field); rows.push(row); return rows; } ```736 tokens in, 359 out · 5.0 s · $0.0025 · 1 message on Pro · answered by google/gemini-4-argon via Google AI Studio ·
GPT-6.1 Sol
Passed: All 8 tests passed.
```javascript function parseCsv(text) { if (text === "") return []; const rows = []; let row = []; let field = ""; let inQuotes = false; let atFieldStart = true; let rowStarted = false; for (let i = 0; i < text.length; i++) { const char = text[i]; rowStarted = true; if (inQuotes) { if (char === '"') { if (text[i + 1] === '"') { field += '"'; i++; } else { inQuotes = false; } } else { field += char; } } else if (char === '"' && atFieldStart) { inQuotes = true; atFieldStart = false; } else if (char === ",") { row.push(field); field = ""; atFieldStart = true; } else if ( char === "\n" || (char === "\r" && text[i + 1] === "\n") ) { if (char === "\r") i++; row.push(field); rows.push(row); row = []; field = ""; atFieldStart = true; rowStarted = false; } else { field += char; atFieldStart = false; } } if (rowStarted) { row.push(field); rows.push(row); } return rows; } ```483 tokens in, 665 out (344 of them reasoning) · 8.4 s · $0.0038 · 1 message on Pro · answered by openai/gpt-6.1-sol via OpenAI ·
DeepSeek V4.1 Flash
Passed: All 8 tests passed.
```javascript function parseCsv(text) { const rows = []; let row = []; let field = ''; let inQuotes = false; let pending = false; // true if there is an in-progress field/row let i = 0; const n = text.length; while (i < n) { const ch = text[i]; if (inQuotes) { if (ch === '"') { if (text[i + 1] === '"') { field += '"'; i += 2; } else { inQuotes = false; i += 1; } } else { field += ch; i += 1; } continue; } if (ch === '"' && field === '') { // A quote only opens a quoted field when it is the first char of the field. inQuotes = true; pending = true; i += 1; continue; } if (ch === ',') { row.push(field); field = ''; pending = true; i += 1; continue; } if (ch === '\n' || ch === '\r') { if (ch === '\r' && text[i + 1] === '\n') i += 1; // treat CRLF as one break row.push(field); rows.push(row); row = []; field = ''; pending = false; i += 1; continue; } field += ch; pending = true; i += 1; } // A line break at the very end leaves "pending" false, so no empty trailing row. if (pending) { row.push(field); rows.push(row); } return rows; } ```522 tokens in, 3,473 out (3,074 of them reasoning) · 9.1 s · $0.0042 · 1 message on Pro · answered by deepseek/deepseek-v4.1-flash via Together ·
Kimi K3
Passed: All 8 tests passed.
```javascript function parseCsv(text) { if (text === "") return []; const rows = []; let row = []; let field = ""; let inQuotes = false; let quoted = false; // current field started with a quote let afterQuote = false; // just closed a quoted field for (let i = 0; i < text.length; i++) { const c = text[i]; if (inQuotes) { if (c === '"') { if (text[i + 1] === '"') { field += '"'; i++; } else { inQuotes = false; afterQuote = true; } } else { field += c; } } else if (c === '"' && field === "" && !afterQuote) { inQuotes = true; quoted = true; } else if (c === ",") { row.push(field); field = ""; quoted = false; afterQuote = false; } else if (c === "\n" || c === "\r") { if (c === "\r" && text[i + 1] === "\n") i++; row.push(field); rows.push(row); row = []; field = ""; quoted = false; afterQuote = false; } else { field += c; } } // Trailing line break doesn't start a new row; otherwise flush last field/row. if (field !== "" || quoted || row.length > 0) { row.push(field); rows.push(row); } return rows; } ```568 tokens in, 367 out (7 of them reasoning) · 4.1 s · $0.0069 · 1 message on Pro · answered by moonshotai/kimi-k3 via Together ·
GPT-6 Sol
Passed: All 8 tests passed.
```javascript function parseCsv(text) { if (text === "") return []; const rows = []; let row = []; let field = ""; let inQuotes = false; let atFieldStart = true; let endedWithRowBreak = false; for (let i = 0; i < text.length; i++) { const char = text[i]; if (inQuotes) { if (char === '"') { if (text[i + 1] === '"') { field += '"'; i++; } else { inQuotes = false; } } else { field += char; } endedWithRowBreak = false; } else if (char === '"' && atFieldStart) { inQuotes = true; atFieldStart = false; endedWithRowBreak = false; } else if (char === ",") { row.push(field); field = ""; atFieldStart = true; endedWithRowBreak = false; } else if (char === "\n" || (char === "\r" && text[i + 1] === "\n")) { row.push(field); rows.push(row); row = []; field = ""; atFieldStart = true; endedWithRowBreak = true; if (char === "\r") i++; } else { field += char; atFieldStart = false; endedWithRowBreak = false; } } if (!endedWithRowBreak) { row.push(field); rows.push(row); } return rows; } ```481 tokens in, 712 out (363 of them reasoning) · 8.9 s · $0.0081 · 1 message on Pro · answered by openai/gpt-6-sol via OpenAI ·
Claude Sonnet 5.5
Passed: All 8 tests passed.
```javascript function parseCsv(text) { const rows = []; let row = []; let field = ""; let inQuotes = false; let fieldStarted = false; // any content or quote seen in current row const n = text.length; for (let i = 0; i < n; i++) { const c = text[i]; if (inQuotes) { if (c === '"') { if (text[i + 1] === '"') { field += '"'; i++; } else { inQuotes = false; } } else { field += c; } continue; } if (c === '"' && field === "" && !fieldStarted) { inQuotes = true; fieldStarted = true; } else if (c === ",") { row.push(field); field = ""; fieldStarted = false; rowHasContent = true; } else if (c === "\n" || (c === "\r" && text[i + 1] === "\n")) { if (c === "\r") i++; row.push(field); rows.push(row); row = []; field = ""; fieldStarted = false; rowHasContent = false; } else { field += c; fieldStarted = true; } } // Final row: only if the text didn't end with a line break if (field !== "" || fieldStarted || row.length > 0 || inQuotes) { row.push(field); rows.push(row); } return rows; } ``` Wait — `rowHasContent` is undeclared, which would throw in strict mode. Here is the corrected version: ```javascript function parseCsv(text) { const rows = []; let row = []; let field = ""; let inQuotes = false; let fieldStarted = false; const n = text.length; for (let i = 0; i < n; i++) { const c = text[i]; if (inQuotes) { if (c === '"') { if (text[i + 1] === '"') { field += '"'; i++; } else { inQuotes = false; } } else { field += c; } continue; } if (c === '"' && !fieldStarted) { inQuotes = true; fieldStarted = true; } else if (c === ",") { row.push(field); field = ""; fieldStarted = false; } else if (c === "\n" || (c === "\r" && text[i + 1] === "\n")) { if (c === "\r") i++; row.push(field); rows.push(row); row = []; field = ""; fieldStarted = false; } else { field += c; fieldStarted = true; } } if (fieldStarted || field !== "" || row.length > 0 || inQuotes) { row.push(field); rows.push(row); } return rows; } ```671 tokens in, 978 out · 5.3 s · $0.0114 · 1 message on Pro · answered by anthropic/claude-sonnet-5.5 via Anthropic ·
Mistral Large 4
Passed: All 8 tests passed.
```javascript function parseCsv(text) { if (text === '') return []; const rows = []; let row = []; let field = ''; let inQuotes = false; let hasField = false; // current field has begun (quote opened or char seen) let i = 0; const endField = () => { row.push(field); field = ''; hasField = false; }; const endRow = () => { endField(); rows.push(row); row = []; }; while (i < text.length) { const ch = text[i]; if (inQuotes) { if (ch === '"') { if (text[i + 1] === '"') { field += '"'; i += 2; } else { inQuotes = false; i++; } } else { field += ch; i++; } continue; } if (ch === '"' && !hasField) { inQuotes = true; hasField = true; i++; } else if (ch === ',') { endField(); i++; } else if (ch === '\n' || ch === '\r') { if (ch === '\r' && text[i + 1] === '\n') i++; endRow(); i++; } else { field += ch; hasField = true; i++; } } // Push the final row unless the text ended with a line break. if (hasField || row.length > 0) { endField(); rows.push(row); } return rows; } ```491 tokens in, 5,505 out (4,808 of them reasoning) · 57.3 s · $0.0118 · 1 message on Pro · answered by mistralai/mistral-large-4-0 via Mistral ·
Claude Sonnet 5
Passed: All 8 tests passed.
```javascript function parseCsv(text) { const rows = []; let row = []; let field = ''; let i = 0; const n = text.length; let inQuotes = false; while (i < n) { const c = text[i]; if (inQuotes) { if (c === '"') { if (text[i + 1] === '"') { field += '"'; i += 2; } else { inQuotes = false; i++; } } else { field += c; i++; } continue; } if (c === '"' && field === '') { inQuotes = true; i++; } else if (c === ',') { row.push(field); field = ''; i++; } else if (c === '\r' && text[i + 1] === '\n') { row.push(field); rows.push(row); row = []; field = ''; i += 2; } else if (c === '\n') { row.push(field); rows.push(row); row = []; field = ''; i++; } else { field += c; i++; } } // Only push the final row if there's actually pending content; // a trailing line break should not create an extra empty row. if (field !== '' || row.length > 0) { row.push(field); rows.push(row); } return rows; } ```667 tokens in, 1,737 out (1,274 of them reasoning) · 15.8 s · $0.0187 · 1 message on Pro · answered by anthropic/claude-sonnet-5 via Claude Platform on AWS ·
Claude Opus 5.5
Passed: All 8 tests passed.
```javascript function parseCsv(text) { const rows = []; const n = text.length; if (n === 0) return rows; let row = []; let field = ''; let inQuotes = false; let atFieldStart = true; // no characters consumed yet for the current field let rowPending = false; // current row has consumed at least one character let i = 0; while (i < n) { const c = text[i]; if (inQuotes) { if (c === '"') { if (text[i + 1] === '"') { field += '"'; i += 2; } else { inQuotes = false; i += 1; } } else { field += c; i += 1; } continue; } if (c === '"' && atFieldStart) { inQuotes = true; atFieldStart = false; rowPending = true; i += 1; continue; } if (c === ',') { row.push(field); field = ''; atFieldStart = true; rowPending = true; i += 1; continue; } if (c === '\n' || (c === '\r' && text[i + 1] === '\n')) { row.push(field); rows.push(row); row = []; field = ''; atFieldStart = true; rowPending = false; i += c === '\r' ? 2 : 1; continue; } field += c; atFieldStart = false; rowPending = true; i += 1; } if (rowPending || inQuotes) { row.push(field); rows.push(row); } return rows; } ```669 tokens in, 1,200 out (637 of them reasoning) · 11.9 s · $0.0273 · 1 message on Pro · answered by anthropic/claude-opus-5.5 via Claude Platform on AWS ·
Gemini 3.1 Pro
Passed: All 8 tests passed.
```javascript function parseCsv(text) { if (text === "") return []; const rows = []; let currentRow = []; let currentField = ""; let inQuotes = false; for (let i = 0; i < text.length; i++) { const c = text[i]; if (inQuotes) { if (c === '"') { if (i + 1 < text.length && text[i + 1] === '"') { currentField += '"'; i++; // Skip escaped quote } else { inQuotes = false; } } else { currentField += c; } } else { if (c === '"' && currentField === "") { inQuotes = true; } else if (c === ',') { currentRow.push(currentField); currentField = ""; } else if (c === '\r' && i + 1 < text.length && text[i + 1] === '\n') { currentRow.push(currentField); rows.push(currentRow); currentRow = []; currentField = ""; i++; // Skip \n } else if (c === '\n') { currentRow.push(currentField); rows.push(currentRow); currentRow = []; currentField = ""; } else { currentField += c; } } } // If the text didn't end with a newline, push the final field and row. // We also push if the very last character was a comma (meaning an empty field at the end). if (currentField !== "" || currentRow.length > 0 || (text.length > 0 && text[text.length - 1] === ',')) { currentRow.push(currentField); rows.push(currentRow); } return rows; } ```515 tokens in, 2,339 out (1,877 of them reasoning) · 20.6 s · $0.0291 · 1 message on Pro · answered by google/gemini-3.1-pro-preview via Google ·
GPT-6 Astra
Passed: All 8 tests passed.
```javascript function parseCsv(text) { if (text === "") return []; const rows = []; let row = []; let field = ""; let inQuotes = false; let atFieldStart = true; for (let i = 0; i < text.length; i++) { const char = text[i]; if (inQuotes) { if (char === '"') { if (text[i + 1] === '"') { field += '"'; i++; } else { inQuotes = false; } } else { field += char; } continue; } if (char === '"' && atFieldStart) { inQuotes = true; atFieldStart = false; } else if (char === ",") { row.push(field); field = ""; atFieldStart = true; } else if ( char === "\n" || (char === "\r" && text[i + 1] === "\n") ) { if (char === "\r") i++; row.push(field); rows.push(row); row = []; field = ""; atFieldStart = true; } else { field += char; atFieldStart = false; } } if (row.length > 0 || !atFieldStart) { row.push(field); rows.push(row); } return rows; } ```481 tokens in, 532 out (219 of them reasoning) · 9.1 s · $0.0314 · 1 message on Pro · answered by openai/gpt-6-astra via OpenAI ·
DeepSeek V4 Pro
Passed: All 8 tests passed.
```javascript function parseCsv(text) { const rows = []; let row = []; let field = ''; let fieldStarted = false; let inQuotes = false; for (let i = 0; i < text.length; i++) { const ch = text[i]; if (inQuotes) { if (ch === '"') { if (text[i + 1] === '"') { field += '"'; i++; } else { inQuotes = false; } } else { field += ch; } continue; } if (ch === '"' && !fieldStarted) { inQuotes = true; fieldStarted = true; } else if (ch === ',') { row.push(field); field = ''; fieldStarted = false; } else if (ch === '\n') { row.push(field); field = ''; fieldStarted = false; rows.push(row); row = []; } else if (ch === '\r') { row.push(field); field = ''; fieldStarted = false; rows.push(row); row = []; if (text[i + 1] === '\n') { i++; } } else { field += ch; fieldStarted = true; } } if (fieldStarted || row.length > 0) { row.push(field); rows.push(row); } return rows; } ```494 tokens in, 8,886 out (8,561 of them reasoning) · 122.3 s · $0.0357 · 1 message on Pro · answered by deepseek/deepseek-v4-pro-0813 via Wafer ·
Grok 4.7
Passed: All 8 tests passed.
```javascript function parseCsv(text) { if (text === "") return []; const rows = []; let row = []; let field = ""; let inQuotes = false; let atFieldStart = true; let endedOnBreak = false; for (let i = 0; i < text.length; ) { const c = text[i]; if (inQuotes) { if (c === '"') { if (text[i + 1] === '"') { field += '"'; i += 2; } else { inQuotes = false; i += 1; } } else { field += c; i += 1; } endedOnBreak = false; continue; } if (atFieldStart && c === '"') { inQuotes = true; atFieldStart = false; endedOnBreak = false; i += 1; continue; } if (c === ",") { row.push(field); field = ""; atFieldStart = true; endedOnBreak = false; i += 1; continue; } if (c === "\n" || (c === "\r" && text[i + 1] === "\n")) { row.push(field); rows.push(row); row = []; field = ""; atFieldStart = true; endedOnBreak = true; i += c === "\r" ? 2 : 1; continue; } field += c; atFieldStart = false; endedOnBreak = false; i += 1; } if (!endedOnBreak) { row.push(field); rows.push(row); } return rows; } ```1,718 tokens in, 5,854 out (5,452 of them reasoning) · 72.2 s · $0.0364 · 1 message on Pro · answered by x-ai/grok-4.7 via xAI ·
Claude Fable 5.1
Passed: All 8 tests passed.
```javascript function parseCsv(text) { const rows = []; if (text.length === 0) return rows; let row = []; let field = ''; let i = 0; const n = text.length; while (i < n) { const ch = text[i]; if (field === '' && ch === '"' && fieldStart) { // Quoted field i++; while (i < n) { const c = text[i]; if (c === '"') { if (text[i + 1] === '"') { field += '"'; i += 2; } else { i++; break; } } else { field += c; i++; } } // After closing quote, consume any trailing chars until delimiter/newline while (i < n && text[i] !== ',' && text[i] !== '\n' && text[i] !== '\r') { field += text[i]; i++; } fieldStart = false; continue; } if (ch === ',') { row.push(field); field = ''; fieldStart = true; i++; } else if (ch === '\n' || (ch === '\r' && text[i + 1] === '\n')) { row.push(field); rows.push(row); row = []; field = ''; fieldStart = true; i += ch === '\r' ? 2 : 1; } else { field += ch; fieldStart = false; i++; } } // Handle final field/row unless text ended exactly on a line break const endsWithNewline = text.endsWith('\n'); if (!endsWithNewline) { row.push(field); rows.push(row); } return rows; // fieldStart tracks whether we're at the beginning of a field (so a quote // there opens a quoted field, while a quote mid-field is a literal char). var fieldStart; } ``` Note: `fieldStart` is declared with `var` (hoisted) and starts `undefined`, which is falsy — so the first field wouldn't be treated as quoted. Here is the corrected version with it initialized properly: ```javascript function parseCsv(text) { const rows = []; if (text.length === 0) return rows; let row = []; let field = ''; let fieldStart = true; let i = 0; const n = text.length; while (i < n) { const ch = text[i]; if (fieldStart && ch === '"') { i++; while (i < n) { const c = text[i]; if (c === '"') { if (text[i + 1] === '"') { field += '"'; i += 2; } else { i++; break; } } else { field += c; i++; } } while (i < n && text[i] !== ',' && text[i] !== '\n' && text[i] !== '\r') { field += text[i]; i++; } fieldStart = false; continue; } if (ch === ',') { row.push(field); field = ''; fieldStart = true; i++; } else if (ch === '\n' || (ch === '\r' && text[i + 1] === '\n')) { row.push(field); rows.push(row); row = []; field = ''; fieldStart = true; i += ch === '\r' ? 2 : 1; } else { field += ch; fieldStart = false; i++; } } if (!text.endsWith('\n')) { row.push(field); rows.push(row); } return rows; } ``` Use the second block.669 tokens in, 1,229 out · 14.3 s · $0.0697 · 1 message on Pro · answered by anthropic/claude-fable-5.1 via Anthropic ·
More coding prompts
The other coding prompts, each with every model's reply, and the results across all five.
Questions
Which AI does best on “Parse CSV with quoted fields”?
19 of 20 models passed this coding prompt's check (tests); Claude Haiku 4.5 didn't. The cheapest reply that passed was GLM 5.3 Flash's, at $0.00026; the fastest, GLM 5.3's in 2.6 s. The dearest reply, Claude Fable 5.1's, cost 267 times as much ($0.0697).
What does a reply to “Parse CSV with quoted fields” cost?
Through the models' APIs, what OpenRouter charged us ran from $0.00026 (GLM 5.3 Flash) to $0.0697 (Claude Fable 5.1) for this prompt. In llmwise you don't pay by the token: a reply like these counts as one message on Pro, whichever model answers.
Claude, GPT, Gemini, DeepSeek, Grok, Kimi, GLM, and Mistral, in one chat.
See what a message costs before you send it. Free is 5 messages to try; sign in with an email link, no password or card.