[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M777V4XKABPJH3VMHGWZR78Z":3,"skill-same:01M777V4XKABPJH3VMHGWZR78Z":46},{"skillNo":4,"name":5,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":21,"frontMatter":22,"refName":23,"commitSha":24,"skillDirectory":25,"forksCount":26,"repositoryHtmlUrl":27,"repositoryHomepageUrl":28,"ownerHtmlUrl":29,"ownerBlogUrl":6,"ownerDescription":30,"updatedAt":31,"install":32,"resources":45},"01M777V4XKABPJH3VMHGWZR78Z","clean-csv-toolkit",null,"Lord1Egypt\u002Fawesome-skill-forge","Lord1Egypt","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F99746359?v=4","01M7592YDNT0XK9WJ0T2MQVPDN","Mohamed Mounir Ali AL Keshita","01M75GRFNHC8VZNWEB8DKDE433",3,"MIT","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fcommunity\u002Fclawhub\u002Fc\u002Fclean-csv-toolkit\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: clean-csv-toolkit\ndescription: Local CSV \u002F TSV \u002F JSONL inspection and cleanup toolkit. Profile, validate, deduplicate, diff, preview (head\u002Ftail\u002Frandom sample), filter with a safe predicate language, sort, concat, merge (inner\u002Fleft\u002Fright\u002Fouter joins), pivot (group-by aggregations + wide cross-tabs), transform (derived columns with safe expression evaluator: profit = revenue - cost, name = upper(first) + last, year(date), coalesce()), and convert between csv\u002Ftsv\u002Fjsonl\u002Fjson\u002Fmarkdown. Pure Python 3 standard library, no pandas, no remote calls. Handles 100k+ rows in under 1 second.\nlicense: MIT\nmetadata: {\"openclaw\":{\"requires\":{\"bins\":[\"python3\"]},\"primaryEnv\":null,\"homepage\":\"https:\u002F\u002Fclawhub.ai\u002Fgopendrasharma89-tech\u002Fclean-csv-toolkit\"}}\n---\n\n# clean-csv-toolkit\n\nv0.5.0\n\nA small honest toolkit for the work agents end up doing constantly: read a CSV someone sent you, work out what's in it, clean it up, and forward only the safe rows downstream. Built on Python 3 standard library only. No `pandas`, no `numpy`, no pip installs, no remote calls.\n\n## What this skill does\n\n- `scripts\u002Finspect.py` — profile a `.csv` \u002F `.tsv` \u002F `.jsonl` file: row count, auto-detected column types (`int`, `float`, `bool`, `date`, `datetime`, `string`, `empty`), null counts per column, distinct value counts (capped), three sample values per column, file size, and detected encoding.\n- `scripts\u002Fvalidate.py` — check the file against a small JSON schema (required columns, per-column type, min\u002Fmax, enum, regex, unique). Exits 0\u002F1 so it slots into CI.\n- `scripts\u002Fdedupe.py` — remove duplicate rows by full-row match or by key columns. Optional `--keep first|last`, `--case-insensitive`, `--trim`, and a JSONL report of every removed row.\n- `scripts\u002Fdiff.py` — compare two files by key column(s) and classify every row as added \u002F removed \u002F changed \u002F unchanged, with a per-column before\u002Fafter diff for changed rows.\n- `scripts\u002Fconvert.py` — convert between CSV, TSV, JSON Lines, JSON array, and GitHub-flavored Markdown table.\n- `scripts\u002Fhead.py` (NEW in v0.2.0) — print the first N rows in csv \u002F tsv \u002F jsonl \u002F md \u002F aligned format, with optional column subset.\n- `scripts\u002Ftail.py` (NEW in v0.2.0) — print the last N rows using a streaming ring buffer (works on multi-gigabyte files without loading them).\n- `scripts\u002Fsample.py` (NEW in v0.2.0) — pick a uniformly random sample of N rows via reservoir sampling. Single-pass, O(N) memory, optional `--seed` for reproducibility, optional `--preserve-order` to keep original row order.\n- `scripts\u002Fmerge.py` (NEW in v0.3.0) — join two files on one or more key columns. Supports `inner` \u002F `left` \u002F `right` \u002F `outer` joins, separate key names per side via `--left-on` and `--right-on`, and duplicate-column disambiguation via `--suffix-left` \u002F `--suffix-right`. Streams the LEFT side, indexes the RIGHT side (peak memory ≈ size of right file).\n- `scripts\u002Fpivot.py` (NEW in v0.3.0) — group-by aggregations and wide pivot tables. Aggregations: `count`, `sum`, `avg`\u002F`mean`, `min`, `max`, `first`, `last`, `nunique`. Set `--pivot-on COL` to produce a wide cross-tab (e.g. region × product, sum of revenue). Numeric-aware `--sort-by` so `--sort-by revenue_sum --desc` orders correctly.\n- `scripts\u002Ffilter.py` (NEW in v0.4.0) — keep rows that match a safe predicate (`amount > 100`, `status in pending,approved`, `email =~ @example\\.com$`, `name is_not_empty`). Supports `==`, `!=`, `\u003C`, `\u003C=`, `>`, `>=`, `=~` (regex), `in`, `contains`, `is_empty` \u002F `is_not_empty` \u002F `is_number` \u002F `is_not_number`. `and` \u002F `or` \u002F parentheses \u002F `not`. NO Python eval — a hand-rolled tokenizer + recursive-descent parser. Optional `--invert`, `--limit`, `--columns`.\n- `scripts\u002Fsort.py` (NEW in v0.4.0) — stable, type-aware sort. Auto-detects which columns are numeric and sorts them numerically (so `1200 > 899 > 100 > 50`, not `\"50\" > \"1200\"`). Per-column direction with `--by amount:desc,region:asc`. Optional `--case-insensitive`, `--limit`, `--numeric` (force numeric on all sort cols).\n- `scripts\u002Fconcat.py` (NEW in v0.4.0) — stack files vertically (UNION ALL). Default mode unions the headers of all inputs; `--strict` requires identical headers; `--add-source COL` tags each row with its source filename; `--dedupe` drops exact-duplicate rows across inputs. Streams one file at a time.\n- `scripts\u002Ftransform.py` (NEW in v0.5.0) — add, modify, rename, drop, cast, or keep columns. Derived columns via a safe expression language (no `eval`): `--add 'profit = revenue - cost'`, `--add 'full_name = upper(first) + \" \" + upper(last)'`, `--add 'year = year(signup_date)'`, `--add 'safe = coalesce(value, default)'`. Built-in functions: upper, lower, strip, len, abs, round, int, float, str, replace, split, join, coalesce, year, month, day. Chainable with `--cast COL:int|float|bool|string`, `--rename OLD=NEW`, `--drop COL[,...]`, `--keep COL[,...]`.\n- `scripts\u002Fcheck_deps.sh` — verify `python3` is available.\n\n## What this skill does not do\n\n- It does not call any LLM, web service, or remote API.\n- It does not load a full dataframe into memory just to do simple structural work; the helpers stream rows where possible.\n- It does not write outside the input\u002Foutput paths the caller provides.\n- It does not do statistical analysis (mean, percentile, correlation). For that, use a dataframe library.\n- It does not parse Excel files (.xls \u002F .xlsx). Export to CSV first.\n\n## Required dependencies\n\n```bash\nbash scripts\u002Fcheck_deps.sh\n```\n\nOnly `python3` is required. The skill uses `csv`, `json`, `re`, `pathlib`, `argparse`, `datetime`, `collections` — all stdlib.\n\n## Workflows\n\n### 0. Quickly preview an unknown CSV (NEW in v0.2.0)\n\n```bash\n# First 10 rows in a clean aligned table\npython3 scripts\u002Fhead.py mystery.csv\n\n# Last 5 rows of a multi-GB log\npython3 scripts\u002Ftail.py huge.csv -n 5\n\n# A reproducible random sample for spot-checking\npython3 scripts\u002Fsample.py customers.csv -n 20 --seed 42\n\n# Preview only specific columns\npython3 scripts\u002Fhead.py customers.csv --columns id,email,status\n\n# Emit a previewable Markdown table for an agent's reply\npython3 scripts\u002Fhead.py customers.csv -n 5 --as md\n```\n\nAll three scripts accept `-n N`, `--as csv|tsv|jsonl|md|aligned`, `--output file`, and `--columns col1,col2,...`. `sample.py` additionally accepts `--seed INT` and `--preserve-order`. Default output format is `aligned` — a fixed-width text table sized to the actual data, which is what an agent usually wants to show inline. Default `N` is 10.\n\nStreaming guarantees:\n- `head.py` reads at most N+1 rows from the file.\n- `tail.py` keeps a bounded `deque(maxlen=N)` and emits only the last N rows.\n- `sample.py` uses reservoir sampling (algorithm R): single pass, O(N) memory regardless of file size.\n\nOn a 100,000-row \u002F 1.6 MB CSV: `head -n 3` runs in ~50 ms, `tail -n 3` in ~180 ms, `sample -n 5` in ~260 ms.\n\n### 1. Profile an unknown CSV\n\n```bash\npython3 scripts\u002Finspect.py customers.csv\n```\n\nOutput:\n\n```\nfile:      \u002Fpath\u002Fcustomers.csv\nsize:      284 B (284 bytes)\nencoding:  utf-8\nkind:      csv\nrows:      5\ncolumns:   6\n\n  #  name                          type           nulls   null%    distinct  sample\n----------------------------------------------------------------------------------------------------\n  1  id                            int                0    0.00           5  '1', '2', '3'\n  2  email                         string             0    0.00           5  'alice@example.com', ...\n  3  name                          string             0    0.00           5  'Alice', 'Bob', 'Carol'\n  4  amount                        float              1   20.00           4  '42.50', '100.00', '7.25'\n  5  status                        string             0    0.00           3  'approved', 'pending', ...\n  6  signup_date                   date               0    0.00           5  '2025-01-15', ...\n```\n\nPass `--json` for machine-readable output that pipes into other tools.\n\nThe script auto-detects the dialect (CSV vs TSV vs JSON Lines) and a sensible encoding (`utf-8`, `utf-8-sig`, `cp1252`, `latin-1`). Type inference takes up to 1000 non-empty values per column and picks the most specific type that fits all of them.\n\n### 2. Validate against a schema\n\nWrite a `schema.json`:\n\n```json\n{\n  \"required_columns\": [\"id\", \"email\", \"amount\", \"status\"],\n  \"columns\": {\n    \"id\":     {\"type\": \"int\", \"required\": true, \"unique\": true, \"min\": 1},\n    \"email\":  {\"type\": \"string\", \"required\": true, \"regex\": \".+@.+\\\\..+\"},\n    \"amount\": {\"type\": \"float\", \"min\": 0, \"max\": 100000},\n    \"status\": {\"type\": \"string\", \"enum\": [\"pending\", \"approved\", \"rejected\"]},\n    \"signup_date\": {\"type\": \"date\"}\n  }\n}\n```\n\nThen:\n\n```bash\npython3 scripts\u002Fvalidate.py customers.csv --schema schema.json\n```\n\nA clean file exits 0 with `verdict: pass`. A bad file exits 1 with a detailed error table:\n\n```\n   row  column                  kind                    detail\n------------------------------------------------------------------------------------------------\n     2  email                   regex_mismatch          value did not match regex | value='not-an-email'\n     2  amount                  bad_type                value does not match type 'float' | value='abc'\n     3  amount                  below_min               value -50.0 \u003C min 0 | value='-50.00'\n     3  status                  not_in_enum             value not in allowed set | value='unknown_status'\n     4  id                      duplicate_unique        value already seen earlier in this column | value='1'\n```\n\nPass `--json` for a structured report and `--max-errors N` to cap collection on huge files.\n\n### 3. Remove duplicates\n\nBy full-row match (any two rows identical in every column):\n\n```bash\npython3 scripts\u002Fdedupe.py messy.csv clean.csv\n```\n\nBy a key column (only one canonical row per `id`):\n\n```bash\npython3 scripts\u002Fdedupe.py messy.csv clean.csv --key id \\\n  --removed-report removed.jsonl\n```\n\n`--keep first` (default) keeps the earlier-occurring row; `--keep last` keeps the later one — useful when later rows are corrections. `--case-insensitive` and `--trim` normalise key values before comparison so `\" alice@example.com\"` and `\"ALICE@example.com\"` collapse to one row.\n\nThe `--removed-report` writes one JSON object per removed row, with the original 1-based row index, the key tuple that was duplicated, and the full row, so the dedup decision is auditable.\n\n### 4. Diff two files\n\n```bash\npython3 scripts\u002Fdiff.py customers_old.csv customers_new.csv --key id\n```\n\nOutput:\n\n```\nadded:      1\nremoved:    1\nchanged:    1\n\n--- ADDED (1) ---\n  + 6\n--- REMOVED (1) ---\n  - 4\n--- CHANGED (1) ---\n  ~ 2\n      amount: '100.00' -> '150.00'\n      status: 'pending' -> 'approved'\n```\n\nMulti-column keys are supported: `--key customer_id,date`. Exit codes are 0 if the files are identical on the key columns, 1 if they differ — so this also works as a CI guard (\"fail the build if the snapshot file changed\").\n\n### 5. Convert between formats\n\n```bash\npython3 scripts\u002Fconvert.py data.csv data.jsonl       # row -> JSON Lines\npython3 scripts\u002Fconvert.py data.jsonl data.csv       # back\npython3 scripts\u002Fconvert.py data.csv data.json --pretty\npython3 scripts\u002Fconvert.py data.csv data.md          # GitHub-flavored table\npython3 scripts\u002Fconvert.py data.tsv data.csv         # delimiter change\n```\n\nOutput format is picked from the extension. Allowed extensions: `.csv`, `.tsv`, `.jsonl`, `.json`, `.md`. The Markdown writer escapes `|` and `\\n` in cell values so the table stays well-formed.\n\n### 6. Join two files (NEW in v0.3.0)\n\n```bash\n# Inner join: only users with at least one order\npython3 scripts\u002Fmerge.py users.csv orders.csv joined.csv \\\n    --left-on id --right-on user_id\n\n# Left join: keep every user, fill unmatched with empty strings\npython3 scripts\u002Fmerge.py users.csv orders.csv left.csv \\\n    --left-on id --right-on user_id --how left\n\n# Same key name on both sides: --on shorthand\npython3 scripts\u002Fmerge.py users.csv orders.csv out.csv --on user_id\n\n# Outer join into JSON Lines, machine-readable summary on stdout\npython3 scripts\u002Fmerge.py a.csv b.csv full.jsonl --on key --how outer --json\n```\n\nDuplicate non-key columns are auto-renamed with `--suffix-left` \u002F `--suffix-right` (defaults `_x` \u002F `_y`).\n\n### 7. Group-by aggregations and wide pivots (NEW in v0.3.0)\n\n```bash\n# Sum revenue per region\npython3 scripts\u002Fpivot.py sales.csv by_region.csv \\\n    --group-by region --agg revenue:sum --sort-by revenue_sum --desc\n\n# Multiple aggregations per group\npython3 scripts\u002Fpivot.py sales.csv detail.csv \\\n    --group-by region,product \\\n    --agg \"units:sum,revenue:sum,revenue:avg,product:nunique\"\n\n# Wide cross-tab: region × product matrix of revenue\npython3 scripts\u002Fpivot.py sales.csv crosstab.csv \\\n    --group-by region --pivot-on product --agg revenue:sum --fill 0\n\n# Same wide pivot rendered as Markdown for a report\npython3 scripts\u002Fpivot.py sales.csv crosstab.md \\\n    --group-by region --pivot-on product --agg revenue:sum --fill \"-\"\n```\n\nAggregation functions: `count`, `sum`, `avg`\u002F`mean`, `min`, `max`, `first`, `last`, `nunique`. Output column names follow `\u003Ccol>_\u003Cfunc>` (e.g. `revenue_sum`). `--sort-by` is numeric-aware: numeric columns are ordered numerically, string columns lexicographically.\n\n### 8. Filter rows (NEW in v0.4.0)\n\n```bash\n# Numeric comparison\npython3 scripts\u002Ffilter.py orders.csv big.csv --where \"amount > 100\"\n\n# Combine boolean conditions\npython3 scripts\u002Ffilter.py orders.csv top.csv \\\n    --where \"status == approved and amount >= 50\"\n\n# Set membership (commas are part of the value, not separators)\npython3 scripts\u002Ffilter.py users.csv targeted.csv \\\n    --where \"country in IN,US,UK and signup_year >= 2024\"\n\n# Regex match\npython3 scripts\u002Ffilter.py users.csv company.csv \\\n    --where 'email =~ @example\\.com$'\n\n# Null \u002F type checks (no right-hand side)\npython3 scripts\u002Ffilter.py users.csv missing.csv --where \"phone is_empty\"\n\n# Invert the predicate, write only specific columns, cap at N matches\npython3 scripts\u002Ffilter.py log.csv non_errors.csv \\\n    --where \"level == ERROR\" --invert --columns ts,msg --limit 1000\n```\n\nThe expression language is deliberately small and is parsed by a hand-rolled tokenizer + recursive-descent parser. There is no `eval`, no shell, no subprocess.\n\n### 9. Sort by one or more columns (NEW in v0.4.0)\n\n```bash\n# Auto-numeric sort, descending\npython3 scripts\u002Fsort.py sales.csv s.csv --by amount:desc\n\n# Multi-key: country ascending, signup_date descending (stable)\npython3 scripts\u002Fsort.py users.csv s.csv --by country:asc,signup_date:desc\n\n# Top 10 by revenue\npython3 scripts\u002Fsort.py sales.csv top10.csv --by revenue:desc --limit 10\n\n# Case-insensitive string sort\npython3 scripts\u002Fsort.py contacts.csv s.csv --by name --case-insensitive\n```\n\nEach `--by` column is treated numerically when every value parses as a number, otherwise string. `--numeric` forces numeric on all sort columns (non-numeric rows sort last).\n\n### 10. Concatenate multiple files (NEW in v0.4.0)\n\n```bash\n# Stack monthly shards into one CSV (header union)\npython3 scripts\u002Fconcat.py all_quarter.csv jan.csv feb.csv mar.csv\n\n# Strict mode: require every input to have an identical header\npython3 scripts\u002Fconcat.py all.csv jan.csv feb.csv mar.csv --strict\n\n# Tag each row with the source filename (without extension)\npython3 scripts\u002Fconcat.py tagged.csv shard_*.csv --add-source origin --source-stem\n\n# Stack + drop duplicate rows across files\npython3 scripts\u002Fconcat.py all.csv jan.csv feb.csv apr.csv --dedupe\n```\n\n### 11. Transform columns (NEW in v0.5.0)\n\n```bash\n# Add a derived column\npython3 scripts\u002Ftransform.py orders.csv with_profit.csv \\\n    --add 'profit = revenue - cost'\n\n# Multiple --add operations + cast + final column selection\npython3 scripts\u002Ftransform.py sales.csv clean.csv \\\n    --add 'profit = revenue - cost' \\\n    --add 'margin_pct = round(profit \u002F revenue * 100, 1)' \\\n    --add 'name = lower(strip(first_name)) + \"_\" + lower(strip(last_name))' \\\n    --add 'signup_year = year(signup)' \\\n    --cast revenue:float --cast cost:float \\\n    --keep id,name,country,revenue,profit,margin_pct,signup_year\n\n# Rename and drop\npython3 scripts\u002Ftransform.py users.csv clean.csv \\\n    --rename 'signup=joined_date' --drop password_hash\n\n# Boolean comparisons produce 0\u002F1 columns\npython3 scripts\u002Ftransform.py orders.csv flagged.csv \\\n    --add 'is_high_value = amount > 1000'\n\n# Fallback for missing values\npython3 scripts\u002Ftransform.py users.csv filled.csv \\\n    --add 'safe_email = coalesce(email, \"unknown@example.com\")'\n```\n\nThe expression language is intentionally small: arithmetic (`+ - * \u002F %`), string concat (`+`), comparisons (`== != \u003C \u003C= > >=` → yield 0\u002F1), parentheses, identifiers (column references), string and number literals, and function calls. **No `eval`, no `subprocess`, no shell.** Empty cells that propagate into arithmetic leave the derived value empty for that row instead of crashing the pipeline.\n\n## Exit codes\n\n| Code | Meaning |\n|---|---|\n| 0 | success \u002F validation pass \u002F files identical |\n| 1 | validation fail \u002F files differ \u002F no rows in input |\n| 2 | bad arguments \u002F unsafe path \u002F missing input \u002F unsupported extension \u002F schema malformed |\n\nThis 0\u002F1\u002F2 split is consistent across all five scripts, so they slot into shell pipelines cleanly:\n\n```bash\npython3 scripts\u002Fvalidate.py incoming.csv --schema schema.json \\\n  && python3 scripts\u002Fdedupe.py incoming.csv clean.csv --key id \\\n  && python3 scripts\u002Finspect.py clean.csv\n```\n\n## Safety properties\n\n- Pure Python 3 standard library. No third-party dependencies.\n- No `subprocess` calls. No shell invocation.\n- All file paths are validated against a strict allowlist regex that rejects shell metacharacters (`;`, `|`, `&`, `>`, `\u003C`, `$`, `` ` ``, backslash-newline, etc.).\n- Scripts only read the input paths the caller provides and write to the output paths the caller provides. No temp files outside the system's tempdir.\n- All inputs and outputs use UTF-8 by default; CSV reads auto-fall-back through utf-8-sig, cp1252, and latin-1 when the file's encoding is non-UTF-8.\n- Deterministic: the same input produces the same output every time.\n\n## Performance\n\n- `inspect.py` profiles 10,000 rows in well under one second on a single core (single-pass streaming read).\n- All scripts stream rows; they do not load the entire file into memory for processing. The exception is `dedupe.py` and `diff.py`, which build an in-memory dict keyed by row identity — fine for hundreds of thousands of rows on a typical laptop.\n- No background threads, no process pool, no caching.\n\n## Known limitations\n\n- Type inference uses regex-shape matching, not locale-aware parsing. `\"1,234.56\"` is detected as `string`, not `float`. Re-export with a different number format if you need different inference.\n- The Markdown writer flattens multi-line cells to single lines (newlines become spaces).\n- JSON Lines input must have one JSON object per line. Multi-line JSON arrays are not supported; use the regular CSV\u002FJSONL pipeline.\n\n## v0.5.0 changes\n\n- Added `scripts\u002Ftransform.py`: derived columns + schema operations. Hand-rolled tokenizer + recursive-descent parser (no `eval`, no subprocess) supports arithmetic (+\u002F-\u002F* \u002F \u002F %), string concat (+), parentheses, function calls, and boolean comparisons that yield 0\u002F1. Built-in functions: upper, lower, strip, len, abs, round, int, float, str, replace, split, join, coalesce, year, month, day. Six op kinds: `--add`, `--set`, `--drop`, `--rename`, `--cast`, `--keep`. Schema is computed symbolically before the streaming pass, so empty cells in arithmetic columns don't crash the whole pipeline — they just leave the derived value empty for that single row.\n- Bug fixed during testing: the schema-detection pass was running expressions against an empty-string row, which broke arithmetic. Replaced with a purely-structural schema walk.\n\n## v0.4.0 changes\n\n- Added `scripts\u002Ffilter.py`: safe-predicate row filter. Hand-rolled tokenizer + recursive-descent parser, NO `eval` and no `subprocess`. Numeric and string compare, regex (`=~`), `in COMMA,LIST`, `contains`, `is_empty` \u002F `is_not_empty` \u002F `is_number` \u002F `is_not_number`. Boolean `and` \u002F `or` \u002F `not` with parentheses. `--invert`, `--limit`, `--columns`.\n- Added `scripts\u002Fsort.py`: type-aware stable sort with per-column direction (`--by amount:desc,region:asc`). Auto-detects numeric columns. Optional `--case-insensitive`, `--limit`, `--numeric`. 100k rows sorted in ~0.3 s.\n- Added `scripts\u002Fconcat.py`: vertical UNION ALL of multiple CSV \u002F TSV \u002F JSONL files. Header union by default, `--strict` for exact-match check, `--add-source` to tag rows, `--dedupe` to drop exact-duplicate rows. Streams one input at a time, memory does not grow with the number of inputs (unless `--dedupe` is set).\n- All three scripts honor the existing safe-path policy and the 0 \u002F 1 \u002F 2 exit-code contract.\n\n## v0.3.0 changes\n\n- Added `scripts\u002Fmerge.py`: join two CSV \u002F TSV \u002F JSONL files on one or more key columns. Supports inner, left, right, outer joins; separate key names per side; duplicate-column suffixing; CSV \u002F TSV \u002F JSONL output. Single-pass over LEFT, peak memory ≈ size of RIGHT. Merged 50k × 200k rows in ~1.3 s.\n- Added `scripts\u002Fpivot.py`: group-by aggregations and wide pivot tables. Functions: count, sum, avg, min, max, first, last, nunique. Wide mode produces region × product cross-tabs. Numeric-aware sort. Streamed 100k rows in ~0.7 s.\n- All new scripts honor the existing safe-path policy (no shell metacharacters), use exit code 2 for bad arguments \u002F missing files \u002F missing columns, exit 1 for empty results, exit 0 for success. Output extension is validated against an explicit allow-list per script.\n\n## v0.2.0 changes\n\n**Three new preview helpers** (`head.py`, `tail.py`, `sample.py`):\n\n- `head.py` and `tail.py` give shell-style preview that is format-aware and never mangles quoting the way a naive `head` \u002F `tail` would. They auto-detect dialect (csv\u002Ftsv\u002Fjsonl), let you pick the output format with `--as`, and can re-emit any subset of columns with `--columns`.\n- `sample.py` runs reservoir sampling (algorithm R): a single streaming pass, O(N) memory regardless of file size. `--seed INT` makes the sample reproducible so it slots into test suites and CI; `--preserve-order` re-sorts the reservoir back into original row order.\n- All three share the same `--as csv|tsv|jsonl|md|aligned`, `--output`, and `--columns` flags, mirroring the convention already used by `convert.py`.\n- Default output format is `aligned`, a fixed-width text table that an agent can paste straight into a reply.\n\n**Performance**: on a 100,000-row \u002F 1.6 MB CSV, `head` runs in ~50 ms, `tail` in ~180 ms, `sample` in ~260 ms.\n\n**No breaking changes**: every v0.1.0 CLI flag, output format, and exit-code contract is preserved.\n\n## License\n\nMIT. See `LICENSE`.\n","# clean-csv-toolkit\n\nv0.5.0\n\nA small honest toolkit for the work agents end up doing constantly: read a CSV someone sent you, work out what's in it, clean it up, and forward only the safe rows downstream. Built on Python 3 standard library only. No `pandas`, no `numpy`, no pip installs, no remote calls.\n\n## What this skill does\n\n- `scripts\u002Finspect.py` — profile a `.csv` \u002F `.tsv` \u002F `.jsonl` file: row count, auto-detected column types (`int`, `float`, `bool`, `date`, `datetime`, `string`, `empty`), null counts per column, distinct value counts (capped), three sample values per column, file size, and detected encoding.\n- `scripts\u002Fvalidate.py` — check the file against a small JSON schema (required columns, per-column type, min\u002Fmax, enum, regex, unique). Exits 0\u002F1 so it slots into CI.\n- `scripts\u002Fdedupe.py` — remove duplicate rows by full-row match or by key columns. Optional `--keep first|last`, `--case-insensitive`, `--trim`, and a JSONL report of every removed row.\n- `scripts\u002Fdiff.py` — compare two files by key column(s) and classify every row as added \u002F removed \u002F changed \u002F unchanged, with a per-column before\u002Fafter diff for changed rows.\n- `scripts\u002Fconvert.py` — convert between CSV, TSV, JSON Lines, JSON array, and GitHub-flavored Markdown table.\n- `scripts\u002Fhead.py` (NEW in v0.2.0) — print the first N rows in csv \u002F tsv \u002F jsonl \u002F md \u002F aligned format, with optional column subset.\n- `scripts\u002Ftail.py` (NEW in v0.2.0) — print the last N rows using a streaming ring buffer (works on multi-gigabyte files without loading them).\n- `scripts\u002Fsample.py` (NEW in v0.2.0) — pick a uniformly random sample of N rows via reservoir sampling. Single-pass, O(N) memory, optional `--seed` for reproducibility, optional `--preserve-order` to keep original row order.\n- `scripts\u002Fmerge.py` (NEW in v0.3.0) — join two files on one or more key columns. Supports `inner` \u002F `left` \u002F `right` \u002F `outer` joins, separate key names per side via `--left-on` and `--right-on`, and duplicate-column disambiguation via `--suffix-left` \u002F `--suffix-right`. Streams the LEFT side, indexes the RIGHT side (peak memory ≈ size of right file).\n- `scripts\u002Fpivot.py` (NEW in v0.3.0) — group-by aggregations and wide pivot tables. Aggregations: `count`, `sum`, `avg`\u002F`mean`, `min`, `max`, `first`, `last`, `nunique`. Set `--pivot-on COL` to produce a wide cross-tab (e.g. region × product, sum of revenue). Numeric-aware `--sort-by` so `--sort-by revenue_sum --desc` orders correctly.\n- `scripts\u002Ffilter.py` (NEW in v0.4.0) — keep rows that match a safe predicate (`amount > 100`, `status in pending,approved`, `email =~ @example\\.com$`, `name is_not_empty`). Supports `==`, `!=`, `\u003C`, `\u003C=`, `>`, `>=`, `=~` (regex), `in`, `contains`, `is_empty` \u002F `is_not_empty` \u002F `is_number` \u002F `is_not_number`. `and` \u002F `or` \u002F parentheses \u002F `not`. NO Python eval — a hand-rolled tokenizer + recursive-descent parser. Optional `--invert`, `--limit`, `--columns`.\n- `scripts\u002Fsort.py` (NEW in v0.4.0) — stable, type-aware sort. Auto-detects which columns are numeric and sorts them numerically (so `1200 > 899 > 100 > 50`, not `\"50\" > \"1200\"`). Per-column direction with `--by amount:desc,region:asc`. Optional `--case-insensitive`, `--limit`, `--numeric` (force numeric on all sort cols).\n- `scripts\u002Fconcat.py` (NEW in v0.4.0) — stack files vertically (UNION ALL). Default mode unions the headers of all inputs; `--strict` requires identical headers; `--add-source COL` tags each row with its source filename; `--dedupe` drops exact-duplicate rows across inputs. Streams one file at a time.\n- `scripts\u002Ftransform.py` (NEW in v0.5.0) — add, modify, rename, drop, cast, or keep columns. Derived columns via a safe expression language (no `eval`): `--add 'profit = revenue - cost'`, `--add 'full_name = upper(first) + \" \" + upper(last)'`, `--add 'year = year(signup_date)'`, `--add 'safe = coalesce(value, default)'`. Built-in functions: upper, lower, strip, len, abs, round, int, float, str, replace, split, join, coalesce, year, month, day. Chainable with `--cast COL:int|float|bool|string`, `--rename OLD=NEW`, `--drop COL[,...]`, `--keep COL[,...]`.\n- `scripts\u002Fcheck_deps.sh` — verify `python3` is available.\n\n## What this skill does not do\n\n- It does not call any LLM, web service, or remote API.\n- It does not load a full dataframe into memory just to do simple structural work; the helpers stream rows where possible.\n- It does not write outside the input\u002Foutput paths the caller provides.\n- It does not do statistical analysis (mean, percentile, correlation). For that, use a dataframe library.\n- It does not parse Excel files (.xls \u002F .xlsx). Export to CSV first.\n\n## Required dependencies\n\n```bash\nbash scripts\u002Fcheck_deps.sh\n```\n\nOnly `python3` is required. The skill uses `csv`, `json`, `re`, `pathlib`, `argparse`, `datetime`, `collections` — all stdlib.\n\n## Workflows\n\n### 0. Quickly preview an unknown CSV (NEW in v0.2.0)\n\n```bash\n# First 10 rows in a clean aligned table\npython3 scripts\u002Fhead.py mystery.csv\n\n# Last 5 rows of a multi-GB log\npython3 scripts\u002Ftail.py huge.csv -n 5\n\n# A reproducible random sample for spot-checking\npython3 scripts\u002Fsample.py customers.csv -n 20 --seed 42\n\n# Preview only specific columns\npython3 scripts\u002Fhead.py customers.csv --columns id,email,status\n\n# Emit a previewable Markdown table for an agent's reply\npython3 scripts\u002Fhead.py customers.csv -n 5 --as md\n```\n\nAll three scripts accept `-n N`, `--as csv|tsv|jsonl|md|aligned`, `--output file`, and `--columns col1,col2,...`. `sample.py` additionally accepts `--seed INT` and `--preserve-order`. Default output format is `aligned` — a fixed-width text table sized to the actual data, which is what an agent usually wants to show inline. Default `N` is 10.\n\nStreaming guarantees:\n- `head.py` reads at most N+1 rows from the file.\n- `tail.py` keeps a bounded `deque(maxlen=N)` and emits only the last N rows.\n- `sample.py` uses reservoir sampling (algorithm R): single pass, O(N) memory regardless of file size.\n\nOn a 100,000-row \u002F 1.6 MB CSV: `head -n 3` runs in ~50 ms, `tail -n 3` in ~180 ms, `sample -n 5` in ~260 ms.\n\n### 1. Profile an unknown CSV\n\n```bash\npython3 scripts\u002Finspect.py customers.csv\n```\n\nOutput:\n\n```\nfile:      \u002Fpath\u002Fcustomers.csv\nsize:      284 B (284 bytes)\nencoding:  utf-8\nkind:      csv\nrows:      5\ncolumns:   6\n\n  #  name                          type           nulls   null%    distinct  sample\n----------------------------------------------------------------------------------------------------\n  1  id                            int                0    0.00           5  '1', '2', '3'\n  2  email                         string             0    0.00           5  'alice@example.com', ...\n  3  name                          string             0    0.00           5  'Alice', 'Bob', 'Carol'\n  4  amount                        float              1   20.00           4  '42.50', '100.00', '7.25'\n  5  status                        string             0    0.00           3  'approved', 'pending', ...\n  6  signup_date                   date               0    0.00           5  '2025-01-15', ...\n```\n\nPass `--json` for machine-readable output that pipes into other tools.\n\nThe script auto-detects the dialect (CSV vs TSV vs JSON Lines) and a sensible encoding (`utf-8`, `utf-8-sig`, `cp1252`, `latin-1`). Type inference takes up to 1000 non-empty values per column and picks the most specific type that fits all of them.\n\n### 2. Validate against a schema\n\nWrite a `schema.json`:\n\n```json\n{\n  \"required_columns\": [\"id\", \"email\", \"amount\", \"status\"],\n  \"columns\": {\n    \"id\":     {\"type\": \"int\", \"required\": true, \"unique\": true, \"min\": 1},\n    \"email\":  {\"type\": \"string\", \"required\": true, \"regex\": \".+@.+\\\\..+\"},\n    \"amount\": {\"type\": \"float\", \"min\": 0, \"max\": 100000},\n    \"status\": {\"type\": \"string\", \"enum\": [\"pending\", \"approved\", \"rejected\"]},\n    \"signup_date\": {\"type\": \"date\"}\n  }\n}\n```\n\nThen:\n\n```bash\npython3 scripts\u002Fvalidate.py customers.csv --schema schema.json\n```\n\nA clean file exits 0 with `verdict: pass`. A bad file exits 1 with a detailed error table:\n\n```\n   row  column                  kind                    detail\n------------------------------------------------------------------------------------------------\n     2  email                   regex_mismatch          value did not match regex | value='not-an-email'\n     2  amount                  bad_type                value does not match type 'float' | value='abc'\n     3  amount                  below_min               value -50.0 \u003C min 0 | value='-50.00'\n     3  status                  not_in_enum             value not in allowed set | value='unknown_status'\n     4  id                      duplicate_unique        value already seen earlier in this column | value='1'\n```\n\nPass `--json` for a structured report and `--max-errors N` to cap collection on huge files.\n\n### 3. Remove duplicates\n\nBy full-row match (any two rows identical in every column):\n\n```bash\npython3 scripts\u002Fdedupe.py messy.csv clean.csv\n```\n\nBy a key column (only one canonical row per `id`):\n\n```bash\npython3 scripts\u002Fdedupe.py messy.csv clean.csv --key id \\\n  --removed-report removed.jsonl\n```\n\n`--keep first` (default) keeps the earlier-occurring row; `--keep last` keeps the later one — useful when later rows are corrections. `--case-insensitive` and `--trim` normalise key values before comparison so `\" alice@example.com\"` and `\"ALICE@example.com\"` collapse to one row.\n\nThe `--removed-report` writes one JSON object per removed row, with the original 1-based row index, the key tuple that was duplicated, and the full row, so the dedup decision is auditable.\n\n### 4. Diff two files\n\n```bash\npython3 scripts\u002Fdiff.py customers_old.csv customers_new.csv --key id\n```\n\nOutput:\n\n```\nadded:      1\nremoved:    1\nchanged:    1\n\n--- ADDED (1) ---\n  + 6\n--- REMOVED (1) ---\n  - 4\n--- CHANGED (1) ---\n  ~ 2\n      amount: '100.00' -> '150.00'\n      status: 'pending' -> 'approved'\n```\n\nMulti-column keys are supported: `--key customer_id,date`. Exit codes are 0 if the files are identical on the key columns, 1 if they differ — so this also works as a CI guard (\"fail the build if the snapshot file changed\").\n\n### 5. Convert between formats\n\n```bash\npython3 scripts\u002Fconvert.py data.csv data.jsonl       # row -> JSON Lines\npython3 scripts\u002Fconvert.py data.jsonl data.csv       # back\npython3 scripts\u002Fconvert.py data.csv data.json --pretty\npython3 scripts\u002Fconvert.py data.csv data.md          # GitHub-flavored table\npython3 scripts\u002Fconvert.py data.tsv data.csv         # delimiter change\n```\n\nOutput format is picked from the extension. Allowed extensions: `.csv`, `.tsv`, `.jsonl`, `.json`, `.md`. The Markdown writer escapes `|` and `\\n` in cell values so the table stays well-formed.\n\n### 6. Join two files (NEW in v0.3.0)\n\n```bash\n# Inner join: only users with at least one order\npython3 scripts\u002Fmerge.py users.csv orders.csv joined.csv \\\n    --left-on id --right-on user_id\n\n# Left join: keep every user, fill unmatched with empty strings\npython3 scripts\u002Fmerge.py users.csv orders.csv left.csv \\\n    --left-on id --right-on user_id --how left\n\n# Same key name on both sides: --on shorthand\npython3 scripts\u002Fmerge.py users.csv orders.csv out.csv --on user_id\n\n# Outer join into JSON Lines, machine-readable summary on stdout\npython3 scripts\u002Fmerge.py a.csv b.csv full.jsonl --on key --how outer --json\n```\n\nDuplicate non-key columns are auto-renamed with `--suffix-left` \u002F `--suffix-right` (defaults `_x` \u002F `_y`).\n\n### 7. Group-by aggregations and wide pivots (NEW in v0.3.0)\n\n```bash\n# Sum revenue per region\npython3 scripts\u002Fpivot.py sales.csv by_region.csv \\\n    --group-by region --agg revenue:sum --sort-by revenue_sum --desc\n\n# Multiple aggregations per group\npython3 scripts\u002Fpivot.py sales.csv detail.csv \\\n    --group-by region,product \\\n    --agg \"units:sum,revenue:sum,revenue:avg,product:nunique\"\n\n# Wide cross-tab: region × product matrix of revenue\npython3 scripts\u002Fpivot.py sales.csv crosstab.csv \\\n    --group-by region --pivot-on product --agg revenue:sum --fill 0\n\n# Same wide pivot rendered as Markdown for a report\npython3 scripts\u002Fpivot.py sales.csv crosstab.md \\\n    --group-by region --pivot-on product --agg revenue:sum --fill \"-\"\n```\n\nAggregation functions: `count`, `sum`, `avg`\u002F`mean`, `min`, `max`, `first`, `last`, `nunique`. Output column names follow `\u003Ccol>_\u003Cfunc>` (e.g. `revenue_sum`). `--sort-by` is numeric-aware: numeric columns are ordered numerically, string columns lexicographically.\n\n### 8. Filter rows (NEW in v0.4.0)\n\n```bash\n# Numeric comparison\npython3 scripts\u002Ffilter.py orders.csv big.csv --where \"amount > 100\"\n\n# Combine boolean conditions\npython3 scripts\u002Ffilter.py orders.csv top.csv \\\n    --where \"status == approved and amount >= 50\"\n\n# Set membership (commas are part of the value, not separators)\npython3 scripts\u002Ffilter.py users.csv targeted.csv \\\n    --where \"country in IN,US,UK and signup_year >= 2024\"\n\n# Regex match\npython3 scripts\u002Ffilter.py users.csv company.csv \\\n    --where 'email =~ @example\\.com$'\n\n# Null \u002F type checks (no right-hand side)\npython3 scripts\u002Ffilter.py users.csv missing.csv --where \"phone is_empty\"\n\n# Invert the predicate, write only specific columns, cap at N matches\npython3 scripts\u002Ffilter.py log.csv non_errors.csv \\\n    --where \"level == ERROR\" --invert --columns ts,msg --limit 1000\n```\n\nThe expression language is deliberately small and is parsed by a hand-rolled tokenizer + recursive-descent parser. There is no `eval`, no shell, no subprocess.\n\n### 9. Sort by one or more columns (NEW in v0.4.0)\n\n```bash\n# Auto-numeric sort, descending\npython3 scripts\u002Fsort.py sales.csv s.csv --by amount:desc\n\n# Multi-key: country ascending, signup_date descending (stable)\npython3 scripts\u002Fsort.py users.csv s.csv --by country:asc,signup_date:desc\n\n# Top 10 by revenue\npython3 scripts\u002Fsort.py sales.csv top10.csv --by revenue:desc --limit 10\n\n# Case-insensitive string sort\npython3 scripts\u002Fsort.py contacts.csv s.csv --by name --case-insensitive\n```\n\nEach `--by` column is treated numerically when every value parses as a number, otherwise string. `--numeric` forces numeric on all sort columns (non-numeric rows sort last).\n\n### 10. Concatenate multiple files (NEW in v0.4.0)\n\n```bash\n# Stack monthly shards into one CSV (header union)\npython3 scripts\u002Fconcat.py all_quarter.csv jan.csv feb.csv mar.csv\n\n# Strict mode: require every input to have an identical header\npython3 scripts\u002Fconcat.py all.csv jan.csv feb.csv mar.csv --strict\n\n# Tag each row with the source filename (without extension)\npython3 scripts\u002Fconcat.py tagged.csv shard_*.csv --add-source origin --source-stem\n\n# Stack + drop duplicate rows across files\npython3 scripts\u002Fconcat.py all.csv jan.csv feb.csv apr.csv --dedupe\n```\n\n### 11. Transform columns (NEW in v0.5.0)\n\n```bash\n# Add a derived column\npython3 scripts\u002Ftransform.py orders.csv with_profit.csv \\\n    --add 'profit = revenue - cost'\n\n# Multiple --add operations + cast + final column selection\npython3 scripts\u002Ftransform.py sales.csv clean.csv \\\n    --add 'profit = revenue - cost' \\\n    --add 'margin_pct = round(profit \u002F revenue * 100, 1)' \\\n    --add 'name = lower(strip(first_name)) + \"_\" + lower(strip(last_name))' \\\n    --add 'signup_year = year(signup)' \\\n    --cast revenue:float --cast cost:float \\\n    --keep id,name,country,revenue,profit,margin_pct,signup_year\n\n# Rename and drop\npython3 scripts\u002Ftransform.py users.csv clean.csv \\\n    --rename 'signup=joined_date' --drop password_hash\n\n# Boolean comparisons produce 0\u002F1 columns\npython3 scripts\u002Ftransform.py orders.csv flagged.csv \\\n    --add 'is_high_value = amount > 1000'\n\n# Fallback for missing values\npython3 scripts\u002Ftransform.py users.csv filled.csv \\\n    --add 'safe_email = coalesce(email, \"unknown@example.com\")'\n```\n\nThe expression language is intentionally small: arithmetic (`+ - * \u002F %`), string concat (`+`), comparisons (`== != \u003C \u003C= > >=` → yield 0\u002F1), parentheses, identifiers (column references), string and number literals, and function calls. **No `eval`, no `subprocess`, no shell.** Empty cells that propagate into arithmetic leave the derived value empty for that row instead of crashing the pipeline.\n\n## Exit codes\n\n| Code | Meaning |\n|---|---|\n| 0 | success \u002F validation pass \u002F files identical |\n| 1 | validation fail \u002F files differ \u002F no rows in input |\n| 2 | bad arguments \u002F unsafe path \u002F missing input \u002F unsupported extension \u002F schema malformed |\n\nThis 0\u002F1\u002F2 split is consistent across all five scripts, so they slot into shell pipelines cleanly:\n\n```bash\npython3 scripts\u002Fvalidate.py incoming.csv --schema schema.json \\\n  && python3 scripts\u002Fdedupe.py incoming.csv clean.csv --key id \\\n  && python3 scripts\u002Finspect.py clean.csv\n```\n\n## Safety properties\n\n- Pure Python 3 standard library. No third-party dependencies.\n- No `subprocess` calls. No shell invocation.\n- All file paths are validated against a strict allowlist regex that rejects shell metacharacters (`;`, `|`, `&`, `>`, `\u003C`, `$`, `` ` ``, backslash-newline, etc.).\n- Scripts only read the input paths the caller provides and write to the output paths the caller provides. No temp files outside the system's tempdir.\n- All inputs and outputs use UTF-8 by default; CSV reads auto-fall-back through utf-8-sig, cp1252, and latin-1 when the file's encoding is non-UTF-8.\n- Deterministic: the same input produces the same output every time.\n\n## Performance\n\n- `inspect.py` profiles 10,000 rows in well under one second on a single core (single-pass streaming read).\n- All scripts stream rows; they do not load the entire file into memory for processing. The exception is `dedupe.py` and `diff.py`, which build an in-memory dict keyed by row identity — fine for hundreds of thousands of rows on a typical laptop.\n- No background threads, no process pool, no caching.\n\n## Known limitations\n\n- Type inference uses regex-shape matching, not locale-aware parsing. `\"1,234.56\"` is detected as `string`, not `float`. Re-export with a different number format if you need different inference.\n- The Markdown writer flattens multi-line cells to single lines (newlines become spaces).\n- JSON Lines input must have one JSON object per line. Multi-line JSON arrays are not supported; use the regular CSV\u002FJSONL pipeline.\n\n## v0.5.0 changes\n\n- Added `scripts\u002Ftransform.py`: derived columns + schema operations. Hand-rolled tokenizer + recursive-descent parser (no `eval`, no subprocess) supports arithmetic (+\u002F-\u002F* \u002F \u002F %), string concat (+), parentheses, function calls, and boolean comparisons that yield 0\u002F1. Built-in functions: upper, lower, strip, len, abs, round, int, float, str, replace, split, join, coalesce, year, month, day. Six op kinds: `--add`, `--set`, `--drop`, `--rename`, `--cast`, `--keep`. Schema is computed symbolically before the streaming pass, so empty cells in arithmetic columns don't crash the whole pipeline — they just leave the derived value empty for that single row.\n- Bug fixed during testing: the schema-detection pass was running expressions against an empty-string row, which broke arithmetic. Replaced with a purely-structural schema walk.\n\n## v0.4.0 changes\n\n- Added `scripts\u002Ffilter.py`: safe-predicate row filter. Hand-rolled tokenizer + recursive-descent parser, NO `eval` and no `subprocess`. Numeric and string compare, regex (`=~`), `in COMMA,LIST`, `contains`, `is_empty` \u002F `is_not_empty` \u002F `is_number` \u002F `is_not_number`. Boolean `and` \u002F `or` \u002F `not` with parentheses. `--invert`, `--limit`, `--columns`.\n- Added `scripts\u002Fsort.py`: type-aware stable sort with per-column direction (`--by amount:desc,region:asc`). Auto-detects numeric columns. Optional `--case-insensitive`, `--limit`, `--numeric`. 100k rows sorted in ~0.3 s.\n- Added `scripts\u002Fconcat.py`: vertical UNION ALL of multiple CSV \u002F TSV \u002F JSONL files. Header union by default, `--strict` for exact-match check, `--add-source` to tag rows, `--dedupe` to drop exact-duplicate rows. Streams one input at a time, memory does not grow with the number of inputs (unless `--dedupe` is set).\n- All three scripts honor the existing safe-path policy and the 0 \u002F 1 \u002F 2 exit-code contract.\n\n## v0.3.0 changes\n\n- Added `scripts\u002Fmerge.py`: join two CSV \u002F TSV \u002F JSONL files on one or more key columns. Supports inner, left, right, outer joins; separate key names per side; duplicate-column suffixing; CSV \u002F TSV \u002F JSONL output. Single-pass over LEFT, peak memory ≈ size of RIGHT. Merged 50k × 200k rows in ~1.3 s.\n- Added `scripts\u002Fpivot.py`: group-by aggregations and wide pivot tables. Functions: count, sum, avg, min, max, first, last, nunique. Wide mode produces region × product cross-tabs. Numeric-aware sort. Streamed 100k rows in ~0.7 s.\n- All new scripts honor the existing safe-path policy (no shell metacharacters), use exit code 2 for bad arguments \u002F missing files \u002F missing columns, exit 1 for empty results, exit 0 for success. Output extension is validated against an explicit allow-list per script.\n\n## v0.2.0 changes\n\n**Three new preview helpers** (`head.py`, `tail.py`, `sample.py`):\n\n- `head.py` and `tail.py` give shell-style preview that is format-aware and never mangles quoting the way a naive `head` \u002F `tail` would. They auto-detect dialect (csv\u002Ftsv\u002Fjsonl), let you pick the output format with `--as`, and can re-emit any subset of columns with `--columns`.\n- `sample.py` runs reservoir sampling (algorithm R): a single streaming pass, O(N) memory regardless of file size. `--seed INT` makes the sample reproducible so it slots into test suites and CI; `--preserve-order` re-sorts the reservoir back into original row order.\n- All three share the same `--as csv|tsv|jsonl|md|aligned`, `--output`, and `--columns` flags, mirroring the convention already used by `convert.py`.\n- Default output format is `aligned`, a fixed-width text table that an agent can paste straight into a reply.\n\n**Performance**: on a 100,000-row \u002F 1.6 MB CSV, `head` runs in ~50 ms, `tail` in ~180 ms, `sample` in ~260 ms.\n\n**No breaking changes**: every v0.1.0 CLI flag, output format, and exit-code contract is preserved.\n\n## License\n\nMIT. See `LICENSE`.\n",{},"master","4aa004da461d820f4ea5499e58eb8d196cf99016","community\u002Fclawhub\u002Fc\u002Fclean-csv-toolkit",0,"https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge","https:\u002F\u002Fskill-explorer-rho.vercel.app","https:\u002F\u002Fgithub.com\u002FLord1Egypt","Unbreakable. Unstoppable. Unmatched⚡.\r\n Speaker of machine tongues 🤖  | World-builder of decentralized dreams 🌐 | Defender of the digital realm🛡️.","2026-06-10 08:21:01",{"source":7,"skillName":5,"commands":33,"prompt":43,"zipAvailable":44},[34,37,40],{"tool":35,"command":36},"npx","npx skills add Lord1Egypt\u002Fawesome-skill-forge --skill clean-csv-toolkit",{"tool":38,"command":39},"bunx","bunx skills add Lord1Egypt\u002Fawesome-skill-forge --skill clean-csv-toolkit",{"tool":41,"command":42},"pnpm","pnpm dlx skills add Lord1Egypt\u002Fawesome-skill-forge --skill clean-csv-toolkit","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fcommunity\u002Fclawhub\u002Fc\u002Fclean-csv-toolkit\u002FSKILL.md",true,[],[47,54,61,68,75,82],{"skillNo":48,"name":49,"nameZh":6,"description":50,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":51,"categories":52,"keywords":53,"publishedAt":18},"01M785WKJB99G3STR1NF9NRTJW","youtube-content","YouTube transcripts to summaries, threads, blogs.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Fyoutube-content\u002FSKILL.md",[],[],{"skillNo":55,"name":56,"nameZh":6,"description":57,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":58,"categories":59,"keywords":60,"publishedAt":18},"01M785WEFHB0G2S9YA6EPR3H0E","xurl","X\u002FTwitter via xurl CLI: post, search, DM, media, v2 API.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Fxurl\u002FSKILL.md",[],[],{"skillNo":62,"name":63,"nameZh":6,"description":64,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":65,"categories":66,"keywords":67,"publishedAt":18},"01M785W98EDN4EFJXJPMQEHCRC","touchdesigner-mcp","Control a running TouchDesigner instance via twozero MCP — create operators, set parameters, wire connections, execute Python, build real-time visuals. 36 native tools.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Ftouchdesigner-mcp\u002FSKILL.md",[],[],{"skillNo":69,"name":70,"nameZh":6,"description":71,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":72,"categories":73,"keywords":74,"publishedAt":18},"01M785W5S9FP3QBH2V191E025P","test-driven-development","TDD: enforce RED-GREEN-REFACTOR, tests before code.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Ftest-driven-development\u002FSKILL.md",[],[],{"skillNo":76,"name":77,"nameZh":6,"description":78,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":79,"categories":80,"keywords":81,"publishedAt":18},"01M785W2AS08NSSH9YATCV6FJB","teams-meeting-pipeline","Operate the Teams meeting summary pipeline via Hermes CLI — summarize meetings, inspect pipeline status, replay jobs, manage Microsoft Graph subscriptions.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Fteams-meeting-pipeline\u002FSKILL.md",[],[],{"skillNo":83,"name":84,"nameZh":6,"description":85,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":86,"categories":87,"keywords":88,"publishedAt":18},"01M785VXKW4T34BTP1SCHW1R7F","systematic-debugging","4-phase root cause debugging: understand bugs before fixing.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Fsystematic-debugging\u002FSKILL.md",[],[]]