Evals / tables / Filter and clean
Filter rows
From gdp.csv keep only the rows for China and save them as china.csv with the header.
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 where [Country Name] = 'China'" -o china.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 |
| China | CHN | 1960 | 59716249310.97416 |
| China | CHN | 1961 | 50056685957.35899 |
| China | CHN | 1962 | 47209186415.35554 |
| China | CHN | 1963 | 50706614526.14723 |
| China | CHN | 1964 | 59708125203.86431 |
| China | CHN | 1965 | 70436008642.42514 |
| China | CHN | 1966 | 76720005491.89641 |
| China | CHN | 1967 | 72881364882.49088 |
| China | CHN | 1968 | 70846276051.47272 |
| China | CHN | 1969 | 79705614854.76736 |
| China | CHN | 1970 | 92602634891.65894 |
| China | CHN | 1971 | 99800593790.98865 |
| China | CHN | 1972 | 113689308020.34328 |
| China | CHN | 1973 | 138543170458.06406 |
| China | CHN | 1974 | 144188970821.072 |
| China | CHN | 1975 | 163429530659.63803 |
| China | CHN | 1976 | 153939265947.7752 |
| China | CHN | 1977 | 174935933078.6625 |
| China | CHN | 1978 | 149540752829.26828 |
| China | CHN | 1979 | 178280594413.0435 |
| China | CHN | 1980 | 191149211575.0 |
| China | CHN | 1981 | 195866382432.53967 |
| China | CHN | 1982 | 205089699858.7786 |
Showing 24 of 65 rows.
How a result is judged (1 check)
- csv: file = "china.csv", columns = 4, contains = ["China"], absent = ["Afghanistan"]
Runs
CodexWithout deftPassed2026-11-07
- Time
- 12s
- New tokens
- 5.9k
- Total input
- 40.3k
- Output tokens
- 0.4k
- Commands
- 2
- Failed
- 0
Trace
I’ll inspect the CSV header and filter the China rows into `china.csv` in the current directory.
pwd && rg --files -g 'gdp.csv' -g 'china.csv'output
gdp.csv
head -n 4 gdp.csv && python3 - <<'PY' import csv from pathlib import Path src=Path('gdp.csv') with src.open(newline='', encoding='utf-8-sig') as f: reader=csv.reader(f) rows=list(reader) if not rows: raise SystemExit('gdp.csv is empty') header=rows[0] # Identify the country field by common header names. normalized=[x.strip().lower() for x in header] choices=('country','country name','nation','economy') idx=next((normalized.index(c) for c in choices if c in normalized), None) if idx is None: raise SystemExit(f'Could not identify country column in header: {header}') with Path('china.csv').open('w', newline='', encoding='utf-8') as out: writer=csv.writer(out) writer.writerow(header) writer.writerows(row for row in rows[1:] if len(row)>idx and row[idx].strip().casefold()=='china') PY wc -l china.csv && head -n 3 china.csvoutput
Country Name,Country Code,Year,Value Afghanistan,AFG,2000,3521418059.923445 Afghanistan,AFG,2001,2813571753.8725324 Afghanistan,AFG,2002,3825701438.9996333 65 china.csv Country Name,Country Code,Year,Value China,CHN,1960,59716249310.97416 China,CHN,1961,50056685957.35899Created [china.csv](china.csv) with the header and all 64 China data rows.
Output
| Country Name | Country Code | Year | Value |
| China | CHN | 1960 | 59716249310.97416 |
| China | CHN | 1961 | 50056685957.35899 |
| China | CHN | 1962 | 47209186415.35554 |
| China | CHN | 1963 | 50706614526.14723 |
| China | CHN | 1964 | 59708125203.86431 |
| China | CHN | 1965 | 70436008642.42514 |
| China | CHN | 1966 | 76720005491.89641 |
| China | CHN | 1967 | 72881364882.49088 |
| China | CHN | 1968 | 70846276051.47272 |
| China | CHN | 1969 | 79705614854.76736 |
| China | CHN | 1970 | 92602634891.65894 |
| China | CHN | 1971 | 99800593790.98865 |
| China | CHN | 1972 | 113689308020.34328 |
| China | CHN | 1973 | 138543170458.06406 |
| China | CHN | 1974 | 144188970821.072 |
| China | CHN | 1975 | 163429530659.63803 |
| China | CHN | 1976 | 153939265947.7752 |
| China | CHN | 1977 | 174935933078.6625 |
| China | CHN | 1978 | 149540752829.26828 |
| China | CHN | 1979 | 178280594413.0435 |
| China | CHN | 1980 | 191149211575.0 |
| China | CHN | 1981 | 195866382432.53967 |
| China | CHN | 1982 | 205089699858.7786 |
Showing 24 of 65 rows.
CodexWith deft, skill installedPassedRead the skillUsed deft2026-11-07
- Time
- 19s
- New tokens
- 9.2k
- Total input
- 101.1k
- Output tokens
- 0.6k
- Commands
- 6
- Failed
- 0
Trace
I’ll inspect the CSV and write the China rows with the original header to `china.csv` in the current directory.
cat .agents/skills/deft/SKILL.mdoutput
--- 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, 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, downlo … 849 more characters
deft find "filter CSV rows by a column value"output
sheet filter sheet -> sheet Keep matching rows: --where "age > 30 and city = 'Oslo'" sheet pivot sheet -> sheet Pivot table: --rows city --columns year --values sales sheet info sheet -> report Sheet names, rows, columns sheet transpose sheet -> sheet Swap rows and columns sheet stats sheet -> report Per-column counts, empties, min, max, mean, sum
rg --files -g 'gdp.csv' -g '*.csv'output
gdp.csv
deft sheet filter --helpoutput
deft sheet filter - Keep matching rows: --where "age > 30 and city = 'Oslo'" Usage: deft sheet filter <sheet>... [-o <sheet|dir>] [options] In: sheet (each handled separately) Out: sheet (default <name>.filtered.<ext>) Compare with = != < <= > >=, contains, startswith, endswith, in (a, b), ~ 'regex'. Join with and, or, not, parentheses. Also: col is empty, col is not empty. Text comparison ignores case. Quote names with spaces: `Unit price` > 3. Options: --where <text> Condition on columns (required) --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 filter people.csv --where 'age > 30' -o older.csv deft sheet filter people.xlsx --where "name in (Ada, Sam)" --to csv -o some.csv Result fields: rows, columns
head -n 3 gdp.csvoutput
Country Name,Country Code,Year,Value Afghanistan,AFG,2000,3521418059.923445 Afghanistan,AFG,2001,2813571753.8725324
deft sheet filter gdp.csv --where \"'Country Name' = 'China'\" -o china.csvoutput
ok sheet.filter gdp.csv -> china.csv 64 rows x 4 columns 0.01s
Saved the 64 China rows, including the header, to [china.csv](china.csv).
Output
| Country Name | Country Code | Year | Value |
| China | CHN | 1960 | 59716249310.97416 |
| China | CHN | 1961 | 50056685957.35899 |
| China | CHN | 1962 | 47209186415.35554 |
| China | CHN | 1963 | 50706614526.14723 |
| China | CHN | 1964 | 59708125203.86431 |
| China | CHN | 1965 | 70436008642.42514 |
| China | CHN | 1966 | 76720005491.89641 |
| China | CHN | 1967 | 72881364882.49088 |
| China | CHN | 1968 | 70846276051.47272 |
| China | CHN | 1969 | 79705614854.76736 |
| China | CHN | 1970 | 92602634891.65894 |
| China | CHN | 1971 | 99800593790.98865 |
| China | CHN | 1972 | 113689308020.34328 |
| China | CHN | 1973 | 138543170458.06406 |
| China | CHN | 1974 | 144188970821.072 |
| China | CHN | 1975 | 163429530659.63803 |
| China | CHN | 1976 | 153939265947.7752 |
| China | CHN | 1977 | 174935933078.6625 |
| China | CHN | 1978 | 149540752829.26828 |
| China | CHN | 1979 | 178280594413.0435 |
| China | CHN | 1980 | 191149211575.0 |
| China | CHN | 1981 | 195866382432.53967 |
| China | CHN | 1982 | 205089699858.7786 |
Showing 24 of 65 rows.
CodexWith deft, skill as AGENTS.mdPassed2026-11-05
- Time
- 16s
- New tokens
- 6.2k
- Total input
- 61.7k
- Output tokens
- 0.6k
- Commands
- 3
- Failed
- 0
Trace
I’ll inspect the CSV header and country column, then write `china.csv` in the current directory with the header preserved.
ls -la && head -n 5 gdp.csvoutput
total 1112 drwxr-xr-x@ 4 user staff 128 Nov 4 20:03 . drwx------@ 3397 user staff 108704 Nov 4 20:03 .. -rw-r--r--@ 1 user staff 1486 Nov 4 20:03 AGENTS.md -rw-r--r--@ 1 user staff 562767 Nov 4 19:32 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
deft sheetoutput
deft sheet - commands (input -> output) info sheet -> report Sheet names, rows, columns convert sheet -> sheet Change format: --to csv|xlsx|json extract sheet -> sheet Take a sheet or range: --sheet, --range A1:D20 merge sheet... -> sheet Stack tables; a shared header is kept once to-md sheet -> md Markdown table (first row is the header) More: deft sheet <command> --help
python3 -c 'import csv; src=\"gdp.csv\"; dst=\"china.csv\"; f=open(src,newline=\"\",encoding=\"utf-8\"); reader=csv.DictReader(f); out=open(dst,\"w\",newline=\"\",encoding=\"utf-8\"); writer=csv.DictWriter(out,fieldnames=reader.fieldnames); writer.writeheader(); n=0 for row in reader: if row[\"Country Name\"] == \"China\": writer.writerow(row); n+=1 out.close(); f.close(); print(f\"Wrote {n} China rows with header to {dst}\")' && head -n 5 china.csv && wc -l china.csvoutput
Wrote 64 China rows with header to china.csv Country Name,Country Code,Year,Value China,CHN,1960,59716249310.97416 China,CHN,1961,50056685957.35899 China,CHN,1962,47209186415.35554 China,CHN,1963,50706614526.14723 65 china.csvSaved [china.csv](china.csv) with the header and 64 China rows.
Output
Its files were not kept in this run. The last line of the trace is its own report.
Claude Opus 5.5Without deftPassed2026-11-07
- Time
- 9s
- New tokens
- 8.9k
- Total input
- 42.2k
- Output tokens
- 0.5k
- Commands
- 0
- Failed
- 0
Trace
Output
| Country Name | Country Code | Year | Value |
| China | CHN | 1960 | 59716249310.97416 |
| China | CHN | 1961 | 50056685957.35899 |
| China | CHN | 1962 | 47209186415.35554 |
| China | CHN | 1963 | 50706614526.14723 |
| China | CHN | 1964 | 59708125203.86431 |
| China | CHN | 1965 | 70436008642.42514 |
| China | CHN | 1966 | 76720005491.89641 |
| China | CHN | 1967 | 72881364882.49088 |
| China | CHN | 1968 | 70846276051.47272 |
| China | CHN | 1969 | 79705614854.76736 |
| China | CHN | 1970 | 92602634891.65894 |
| China | CHN | 1971 | 99800593790.98865 |
| China | CHN | 1972 | 113689308020.34328 |
| China | CHN | 1973 | 138543170458.06406 |
| China | CHN | 1974 | 144188970821.072 |
| China | CHN | 1975 | 163429530659.63803 |
| China | CHN | 1976 | 153939265947.7752 |
| China | CHN | 1977 | 174935933078.6625 |
| China | CHN | 1978 | 149540752829.26828 |
| China | CHN | 1979 | 178280594413.0435 |
| China | CHN | 1980 | 191149211575.0 |
| China | CHN | 1981 | 195866382432.53967 |
| China | CHN | 1982 | 205089699858.7786 |
Showing 24 of 65 rows.
Claude Opus 5.5With deft, skill installedPassedRead the skillUsed deft2026-11-07
- Time
- 37s
- New tokens
- 12.2k
- Total input
- 111.8k
- Output tokens
- 1.2k
- 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 |
| China | CHN | 1960 | 59716249310.97416 |
| China | CHN | 1961 | 50056685957.35899 |
| China | CHN | 1962 | 47209186415.35554 |
| China | CHN | 1963 | 50706614526.14723 |
| China | CHN | 1964 | 59708125203.86431 |
| China | CHN | 1965 | 70436008642.42514 |
| China | CHN | 1966 | 76720005491.89641 |
| China | CHN | 1967 | 72881364882.49088 |
| China | CHN | 1968 | 70846276051.47272 |
| China | CHN | 1969 | 79705614854.76736 |
| China | CHN | 1970 | 92602634891.65894 |
| China | CHN | 1971 | 99800593790.98865 |
| China | CHN | 1972 | 113689308020.34328 |
| China | CHN | 1973 | 138543170458.06406 |
| China | CHN | 1974 | 144188970821.072 |
| China | CHN | 1975 | 163429530659.63803 |
| China | CHN | 1976 | 153939265947.7752 |
| China | CHN | 1977 | 174935933078.6625 |
| China | CHN | 1978 | 149540752829.26828 |
| China | CHN | 1979 | 178280594413.0435 |
| China | CHN | 1980 | 191149211575.0 |
| China | CHN | 1981 | 195866382432.53967 |
| China | CHN | 1982 | 205089699858.7786 |
Showing 24 of 65 rows.
Claude CodeWithout deftNot run yet
Claude CodeWith deftNot run yet