🥇 Claude 3.5 Sonnet
47 / 50 · 3.0‰ cent per runClean docstring, handles chardet-free encoding detection via BOM check + fallbacks. Used csv.Sniffer correctly. 52 lines.
Task: Write a Python function that parses a CSV file with inconsistent delimiters.
Claude 3.5 Sonnet is the quality winner on robustness and docstring clarity. DeepSeek V3 is the price-performance king if you're batching thousands of coding calls. Avoid Llama 3.3 70B here — it missed basic delimiter detection cases.
Write a Python function called `parse_csv_robust(path: str) -> list[dict]` that: 1. Automatically detects the delimiter (could be comma, semicolon, tab, pipe) 2. Handles files where some rows have more fields than others 3. Returns a list of dicts keyed by the first row's headers 4. Handles UTF-8, UTF-16, and Latin-1 encodings gracefully 5. Includes type hints and a docstring with one usage example Do NOT use pandas. Only stdlib. Keep it under 60 lines.
| Rank | Model | Total /50 | Cost / run |
|---|---|---|---|
| 🥇 | Claude 3.5 Sonnet | 47 | 3.0‰ cent |
| 🥈 | DeepSeek V3 | 45 | 0.8‰ cent |
| 🥉 | GPT-4o | 42 | 5.0‰ cent |
| #4 | Gemini 2.0 Flash | 39 | 0.5‰ cent |
| #5 | Llama 3.3 70B | 36 | 0.2‰ cent |
Clean docstring, handles chardet-free encoding detection via BOM check + fallbacks. Used csv.Sniffer correctly. 52 lines.
Surprisingly tight 48-line solution. Handled all 3 encoding cases. Price-performance leader for this task.
Correct and robust but slightly over-engineered — 58 lines, added a logging call that wasn't asked for. Delimiter detection used sniff() with explicit candidates (good).
Correct on 2/3 edge cases we threw at it. Missed Latin-1 fallback on the UTF-16 BOM test. Compact (45 lines) and readable.
Correct for comma/semicolon but missed pipe-delimited test. No encoding fallback.