Evals / tables / Filter and clean
Largest values first
Sort gdp.csv by Value from largest to smallest and save it as ranked.csv.
The task
The reference answer shows the job can be done with deft. It is not an agent run.
deft sheet query gdp.csv --sql "select * from gdp order by Value desc" -o ranked.csv
Input
| Country Name | Country Code | Year | Value |
| Afghanistan | AFG | 2000 | 3521418059.923445 |
| Afghanistan | AFG | 2001 | 2813571753.8725324 |
| Afghanistan | AFG | 2002 | 3825701438.9996333 |
| Afghanistan | AFG | 2003 | 4520946818.545814 |
| Afghanistan | AFG | 2004 | 5224896718.67782 |
| Afghanistan | AFG | 2005 | 6203256538.709669 |
| Afghanistan | AFG | 2006 | 6971758282.293506 |
| Afghanistan | AFG | 2007 | 9747886187.393929 |
| Afghanistan | AFG | 2008 | 10109297047.543194 |
| Afghanistan | AFG | 2009 | 12416152732.056717 |
| Afghanistan | AFG | 2010 | 15856668555.833595 |
| Afghanistan | AFG | 2011 | 17805098206.314083 |
| Afghanistan | AFG | 2012 | 19907329777.587166 |
| Afghanistan | AFG | 2013 | 20146416757.598675 |
| Afghanistan | AFG | 2014 | 20497128555.69723 |
| Afghanistan | AFG | 2015 | 19134221644.732494 |
| Afghanistan | AFG | 2016 | 18116572395.077213 |
| Afghanistan | AFG | 2017 | 18753456497.815865 |
| Afghanistan | AFG | 2018 | 18053222687.412624 |
| Afghanistan | AFG | 2019 | 18799444490.11278 |
| Afghanistan | AFG | 2020 | 19955929052.149597 |
| Afghanistan | AFG | 2021 | 14266499429.874573 |
| Afghanistan | AFG | 2022 | 14502158192.090395 |
Showing 24 of 4985 rows.
Reference output
| Country Name | Country Code | Year | Value |
| World | WLD | 2023 | 105435039507024.1 |
| World | WLD | 2022 | 101225059591362.84 |
| World | WLD | 2021 | 97527032881901.1 |
| World | WLD | 2019 | 87945574337517.84 |
| World | WLD | 2018 | 86686870786621.52 |
| World | WLD | 2020 | 85577718250195.55 |
| World | WLD | 2017 | 81550955754739.27 |
| World | WLD | 2014 | 79894385759929.17 |
| World | WLD | 2013 | 77751368312765.5 |
| World | WLD | 2016 | 76588030455295.45 |
| World | WLD | 2012 | 75603976718162.81 |
| World | WLD | 2015 | 75359657218242.52 |
| World | WLD | 2011 | 73957792909770.53 |
| High income | HIC | 2023 | 67653743404264.14 |
| World | WLD | 2010 | 66514174634776.0 |
| High income | HIC | 2022 | 64444446480056.59 |
| OECD members | OED | 2023 | 64098865773302.98 |
| World | WLD | 2008 | 64072295929643.414 |
| High income | HIC | 2021 | 62461025675219.586 |
| World | WLD | 2009 | 60718262754480.14 |
| OECD members | OED | 2022 | 60170092967268.375 |
| Post-demographic dividend | PST | 2023 | 59851800976561.17 |
| OECD members | OED | 2021 | 58899843230643.734 |
Showing 24 of 4431 rows.
How a result is judged (1 check)
- python: code = "import csv; r = list(csv.DictReader(open('ranked.csv'))); v = [float(x['Value']) for x in r[:50]]; assert v == sorted(v, reverse=True) and len(r) > 1000"
Runs
CodexWithout deftPassed2026-11-07
- Time
- 12s
- New tokens
- 3.5k
- Total input
- 40.4k
- Output tokens
- 0.4k
- Commands
- 2
- Failed
- 0
Trace
I’ll inspect the CSV header and sort its rows by the `Value` column descending, then save the result as `ranked.csv` in the current directory.
ls -l gdp.csv && head -n 5 gdp.csvoutput
-rw-r--r--@ 1 user staff 562767 Nov 5 21:11 gdp.csv Country Name,Country Code,Year,Value Afghanistan,AFG,2000,3521418059.923445 Afghanistan,AFG,2001,2813571753.8725324 Afghanistan,AFG,2002,3825701438.9996333 Afghanistan,AFG,2003,4520946818.545814
python3 -c 'import csv; src=\"gdp.csv\"; dst=\"ranked.csv\"; f=open(src,newline=\"\",encoding=\"utf-8\"); reader=csv.DictReader(f); rows=list(reader); fields=reader.fieldnames; rows.sort(key=lambda row: float(row[\"Value\"]), reverse=True); out=open(dst,\"w\",newline=\"\",encoding=\"utf-8\"); writer=csv.DictWriter(out,fieldnames=fields); writer.writeheader(); writer.writerows(rows); out.close(); f.close(); print(f\"Wrote {len(rows)} rows to {dst}\")'output
Wrote 13979 rows to ranked.csv
Sorted `gdp.csv` by `Value` from largest to smallest and saved 13,979 rows to [ranked.csv](ranked.csv).
Output
| Country Name | Country Code | Year | Value |
| World | WLD | 2023 | 105435039507024.1 |
| World | WLD | 2022 | 101225059591362.84 |
| World | WLD | 2021 | 97527032881901.1 |
| World | WLD | 2019 | 87945574337517.84 |
| World | WLD | 2018 | 86686870786621.52 |
| World | WLD | 2020 | 85577718250195.55 |
| World | WLD | 2017 | 81550955754739.27 |
| World | WLD | 2014 | 79894385759929.17 |
| World | WLD | 2013 | 77751368312765.5 |
| World | WLD | 2016 | 76588030455295.45 |
| World | WLD | 2012 | 75603976718162.81 |
| World | WLD | 2015 | 75359657218242.52 |
| World | WLD | 2011 | 73957792909770.53 |
| High income | HIC | 2023 | 67653743404264.14 |
| World | WLD | 2010 | 66514174634776.0 |
| High income | HIC | 2022 | 64444446480056.59 |
| OECD members | OED | 2023 | 64098865773302.98 |
| World | WLD | 2008 | 64072295929643.414 |
| High income | HIC | 2021 | 62461025675219.586 |
| World | WLD | 2009 | 60718262754480.14 |
| OECD members | OED | 2022 | 60170092967268.375 |
| Post-demographic dividend | PST | 2023 | 59851800976561.17 |
| OECD members | OED | 2021 | 58899843230643.734 |
Showing 24 of 4324 rows.
CodexWith deft, skill installedPassedRead the skillUsed deft2026-11-07
- Time
- 19s
- New tokens
- 9.9k
- Total input
- 102.4k
- Output tokens
- 0.6k
- Commands
- 6
- Failed
- 0
Trace
I’ll inspect the CSV structure and sort its rows by the `Value` column in descending order, preserving the header in `ranked.csv`.
cat .agents/skills/deft/SKILL.mdoutput
--- name: deft description: "Use deft instead of writing a script for file jobs: PDF merge/split/compress/watermark, image resize/convert/compress, video and audio trim/convert/compress, spreadsheets, Markdown to PDF/HTML, and YouTube downloads and subtitles." --- # deft One local command for file jobs. Prefer it over writing Python or shell scripts. Syntax: `deft <group> <command> [inputs] [-o output] [--options]` Groups: - `pdf`: Merge, split, compress, encrypt, forms, OCR, compare, convert - `image`: Resize, crop, convert, compress, filters, montage, OCR - `video`: Trim, crop, speed, convert, compress, GIF, frames (ffmpeg) - `audio`: Convert, trim, merge, fade, speed, tag, normalize (ffmpeg) - `doc`: Word/ODT/RTF: to text, Markdown, HTML, PDF; find and replace - `slides`: PowerPoint: extract text, Markdown outline, PDF handout - `data`: JSON/YAML/TOML/XML: convert, query with jq syntax, merge, diff - `sheet`: Excel/CSV/ODS tables: filter, sort, join, pivot, convert - `md`: Markdown to PDF, HTML, Word, EPUB; table of contents - `html`: HTML to Markdown, text, Word, PDF; screenshots - `epub`: E-books: info, to text, Markdown and PDF - `email`: EML files: headers, text, attachments - `contact`: VCF address books: to and from CSV - `calendar`: ICS calendars: to and from CSV - `gps`: GPX and KML tracks: convert, distance and time - `youtube`: Info, download, audio, subtitles, thumbnail (yt-dlp) - `file`: Any file: hash, duplicates, batch rename, base64, encoding - `qr`: Cre … 728 more characters
I’m using the `deft` spreadsheet workflow for this CSV sort. I’ll check the available sort options and the file’s columns, then write `ranked.csv`.
deft sheetoutput
deft sheet - commands (input -> output) info sheet -> report Sheet names, rows, columns convert sheet -> sheet Change format: --to csv|xlsx|json dedupe sheet -> sheet Drop repeated rows, by whole row or --columns extract sheet -> sheet Take a sheet or range: --sheet, --range A1:D20 filter sheet -> sheet Keep matching rows: --where "age > 30 and city = 'Oslo'" from-pdf pdf -> sheet All text as one table [beta] group sheet -> sheet Group and total: --columns city --values sales --agg sum join sheet... -> sheet Join two tables on a key: --on id --how left merge sheet... -> sheet Stack tables; a shared header is kept once pivot sheet -> sheet Pivot table: --rows city --columns year --values sales query sheet|sqlite... -> sheet Run SQL over tables or a SQLite file: --sql 'select ...' select sheet -> sheet Keep, reorder or --drop columns sort sheet -> sheet Sort rows: --columns age,name --descending split sheet -> sheet... Split up: --sheets, --columns city or --every 1000 stats sheet -> report Per-column counts, empties, min, max, mean, sum to-md sheet -> md Markdown table (first row is the header) transpose sheet -> sheet Swap rows and columns More: deft sheet <command> --help
deft sheet sort --helpoutput
deft sheet sort - Sort rows: --columns age,name --descending Usage: deft sheet sort <sheet>... [-o <sheet|dir>] [options] In: sheet (each handled separately) Out: sheet (default <name>.sorted.<ext>) Numbers sort as numbers; empty cells go last. Options: --columns <text> Column names or numbers, comma-separated (required) --descending Largest first --sheet <text> Sheet name or number (default: first) --to <csv|xlsx|json> Output format (default: like the input) Common: -o --force --dry-run --json -j (deft help common) Examples: deft sheet sort people.csv --columns age --descending -o ranked.csv Result fields: rows, columns
deft sheet info gdp.csvoutput
ok sheet.info gdp.csv gdp: 13980 rows x 4 columns sheets=[{"name":"gdp","rows":13980,"columns":4}]head -n 4 gdp.csvoutput
Country Name,Country Code,Year,Value Afghanistan,AFG,2000,3521418059.923445 Afghanistan,AFG,2001,2813571753.8725324 Afghanistan,AFG,2002,3825701438.9996333
deft sheet sort gdp.csv --columns Value --descending -o ranked.csvoutput
ok sheet.sort gdp.csv -> ranked.csv 13979 rows x 4 columns 0.14s
Sorted `gdp.csv` by `Value` from largest to smallest and saved it as [ranked.csv](ranked.csv).
Output
| Country Name | Country Code | Year | Value |
| World | WLD | 2023 | 105435039507024.1 |
| World | WLD | 2022 | 101225059591362.84 |
| World | WLD | 2021 | 97527032881901.1 |
| World | WLD | 2019 | 87945574337517.84 |
| World | WLD | 2018 | 86686870786621.52 |
| World | WLD | 2020 | 85577718250195.55 |
| World | WLD | 2017 | 81550955754739.27 |
| World | WLD | 2014 | 79894385759929.17 |
| World | WLD | 2013 | 77751368312765.5 |
| World | WLD | 2016 | 76588030455295.45 |
| World | WLD | 2012 | 75603976718162.81 |
| World | WLD | 2015 | 75359657218242.52 |
| World | WLD | 2011 | 73957792909770.53 |
| High income | HIC | 2023 | 67653743404264.14 |
| World | WLD | 2010 | 66514174634776.0 |
| High income | HIC | 2022 | 64444446480056.59 |
| OECD members | OED | 2023 | 64098865773302.98 |
| World | WLD | 2008 | 64072295929643.414 |
| High income | HIC | 2021 | 62461025675219.586 |
| World | WLD | 2009 | 60718262754480.14 |
| OECD members | OED | 2022 | 60170092967268.375 |
| Post-demographic dividend | PST | 2023 | 59851800976561.17 |
| OECD members | OED | 2021 | 58899843230643.734 |
Showing 24 of 4431 rows.
Claude Opus 5.5Without deftPassed2026-11-07
- Time
- 10s
- New tokens
- 9.0k
- Total input
- 42.0k
- Output tokens
- 0.6k
- Commands
- 0
- Failed
- 0
Trace
Output
| Country Name | Country Code | Year | Value |
| World | WLD | 2023 | 105435039507024.1 |
| World | WLD | 2022 | 101225059591362.84 |
| World | WLD | 2021 | 97527032881901.1 |
| World | WLD | 2019 | 87945574337517.84 |
| World | WLD | 2018 | 86686870786621.52 |
| World | WLD | 2020 | 85577718250195.55 |
| World | WLD | 2017 | 81550955754739.27 |
| World | WLD | 2014 | 79894385759929.17 |
| World | WLD | 2013 | 77751368312765.5 |
| World | WLD | 2016 | 76588030455295.45 |
| World | WLD | 2012 | 75603976718162.81 |
| World | WLD | 2015 | 75359657218242.52 |
| World | WLD | 2011 | 73957792909770.53 |
| High income | HIC | 2023 | 67653743404264.14 |
| World | WLD | 2010 | 66514174634776.0 |
| High income | HIC | 2022 | 64444446480056.59 |
| OECD members | OED | 2023 | 64098865773302.98 |
| World | WLD | 2008 | 64072295929643.414 |
| High income | HIC | 2021 | 62461025675219.586 |
| World | WLD | 2009 | 60718262754480.14 |
| OECD members | OED | 2022 | 60170092967268.375 |
| Post-demographic dividend | PST | 2023 | 59851800976561.17 |
| OECD members | OED | 2021 | 58899843230643.734 |
Showing 24 of 4324 rows.
Claude Opus 5.5With deft, skill installedPassedRead the skillUsed deft2026-11-07
- Time
- 20s
- New tokens
- 11.2k
- Total input
- 76.9k
- Output tokens
- 0.8k
- Commands
- 0
- Failed
- 0
Trace
Output
--- name: deft description: "Use deft first for any simple, direct operation on local files, whatever the type: convert, read, extract, edit, compress, merge, split, compare or inspect. Try it before writing a script or one-liner. If unsure, run deft find; if it says no command does this, use another tool. Not for programming work: to read, write or change source code, skip it." --- # deft One local command for file jobs. Prefer it over writing Python or shell scripts. Syntax: `deft <group> <command> [inputs] [-o output] [--options]` Groups: - `pdf`: Merge, split, compress, encrypt, forms, OCR, compare, convert - `image`: Resize, crop, convert, compress, adjust, montage, OCR - `video`: Trim, merge, convert, compress, subtitles, GIF, frames (ffmpeg) - `audio`: Convert, trim, normalize, denoise, cut silence (ffmpeg) - `doc`: Word/ODT/RTF: to text, Markdown, HTML, PDF; find and replace - `slides`: PowerPoint: extract text, Markdown outline - `sheet`: Excel/CSV/ODS tables: SQL query, pivot, merge, split, convert - `json`: JSON: convert, format, merge, diff, validate - `toml`: TOML: convert, format, merge, diff, validate - `xml`: XML: convert, format, merge, diff, validate - `yaml`: YAML: convert, format, merge, diff, validate - `md`: Markdown to PDF, HTML, Word, EPUB; table of contents - `html`: HTML to Markdown, text, Word and PDF - `epub`: E-books: info, to text, Markdown and PDF - `gps`: GPX and KML tracks: convert, distance and time - `qr`: Create QR codes and barcodes; read QR codes How to use it: 1. Run `deft <group>` to list commands, or `deft find "<what you want>"` to search. If it says `no command does this`, use another tool. 2. Run `deft <group> <command> --help` for options and examples. 3. `deft convert <in> -o <out.ext>` converts between formats by extension. 4. Results are one line starting with `ok`, `partial` or `error`; add `--json` to parse them. Errors include a `hint:` with the fix. Inputs are never overwritten; pass `--force` or `--in-place` to allow it. Globs and directories work as inputs; several inputs run in parallel. If `deft` is not installed, ask the user, then follow https://github.com/firstprayer/deft/blob/main/docs/INSTALL.md
| Country Name | Country Code | Year | Value |
| World | WLD | 2023 | 105435039507024.1 |
| World | WLD | 2022 | 101225059591362.84 |
| World | WLD | 2021 | 97527032881901.1 |
| World | WLD | 2019 | 87945574337517.84 |
| World | WLD | 2018 | 86686870786621.52 |
| World | WLD | 2020 | 85577718250195.55 |
| World | WLD | 2017 | 81550955754739.27 |
| World | WLD | 2014 | 79894385759929.17 |
| World | WLD | 2013 | 77751368312765.5 |
| World | WLD | 2016 | 76588030455295.45 |
| World | WLD | 2012 | 75603976718162.81 |
| World | WLD | 2015 | 75359657218242.52 |
| World | WLD | 2011 | 73957792909770.53 |
| High income | HIC | 2023 | 67653743404264.14 |
| World | WLD | 2010 | 66514174634776.0 |
| High income | HIC | 2022 | 64444446480056.59 |
| OECD members | OED | 2023 | 64098865773302.98 |
| World | WLD | 2008 | 64072295929643.414 |
| High income | HIC | 2021 | 62461025675219.586 |
| World | WLD | 2009 | 60718262754480.14 |
| OECD members | OED | 2022 | 60170092967268.375 |
| Post-demographic dividend | PST | 2023 | 59851800976561.17 |
| OECD members | OED | 2021 | 58899843230643.734 |
Showing 24 of 4431 rows.
Claude CodeWithout deftNot run yet
Claude CodeWith deftNot run yet