# Value Counts for a CSV Column

Count distinct values in a chosen CSV column with counts and percentages. Pick a header or column index, sort by count or value, and include blanks if needed.

## Run it

- **CLI:** `gizza tool value-counts "fruit
apple
banana
apple
cherry
apple
banana" 'column=fruit'`
- **Web:** https://gizza.ai/tools/value-counts/
- **Agents:** machine-readable descriptor (parameters JSON Schema) at https://gizza.ai/tools/value-counts/tool.json

## Inputs

- `data` — CSV/table data (first row is a header) _(field)_
- `column` — Column (header name or 1-based index) _(field)_
- `delimiter` — Delimiter _(field)_
- `sort` — Sort rows by _(field)_
- `case_sensitive` — Case-sensitive grouping _(field)_
- `include_empty` — Include blank cells as (empty) _(field)_

## Output

- Value counts CSV (text)

## Query parameters

Open the tool pre-filled and auto-run via URL:

- `data` — CSV/table data (first row is a header)
- `column` — Column (header name or 1-based index)
- `delimiter` — Delimiter
- `sort` — Sort rows by
- `case_sensitive` — Case-sensitive grouping
- `include_empty` — Include blank cells as (empty)

Example: `https://gizza.ai/tools/value-counts/?data=fruit%0Aapple%0Abanana%0Aapple%0Acherry%0Aapple%0Abanana&column=fruit&delimiter=%2C&sort=count&case_sensitive=true&include_empty=true`

---

## Count category values in one CSV column

Paste a CSV or delimited table, choose a single column by header name or 1-based
index, and this tool returns a compact `value,count,percent` CSV. It is the
browser-local version of the pandas `Series.value_counts()` workflow: count each
distinct value, compute its share of the counted rows, and sort the result by
frequency or by value.

### Worked example

Input:

```csv
fruit
apple
banana
apple
cherry
apple
banana
```

With **Column = fruit**, the output is:

```csv
value,count,percent
apple,3,50%
banana,2,33.33%
cherry,1,16.67%
```

Use **Case-sensitive grouping** off to group `Open`, `open`, and `OPEN` together
while keeping the first spelling. Turn **Include blank cells** on to count blank
cells as `(empty)` instead of skipping them.

### Limits & edge cases

- The first row is always treated as the header. Pick a column by exact header
  name or by 1-based position (`1`, `2`, ...).
- Blank cells are skipped by default. When included, whitespace-only cells count
  as `(empty)`.
- Percentages use the total counted values as the denominator and are rounded to
  at most two decimals.
- Ties in **Sort by count** keep the first-seen order from the input column.
- CSV quoting is handled by the Rust `csv` parser/writer, so commas inside quoted
  fields are preserved.

## FAQ

<details>
<summary>How is this different from count-line-frequency?</summary>

`count-line-frequency` treats every input line as one value. This tool parses a
CSV/table first and counts only the column you choose, then adds a percentage
column and delimiter-aware output.

</details>

<details>
<summary>Can I count a tab- or semicolon-delimited file?</summary>

Yes. Set **Delimiter** to `tab`, `semicolon`, `pipe`, `comma`, or any single
character. The output uses the same delimiter so it can be pasted back into a
spreadsheet.

</details>

<details>
<summary>What happens to empty cells?</summary>

They are skipped by default, matching the common "drop missing values" workflow.
Enable **Include blank cells** to count every blank or whitespace-only cell as the
literal value `(empty)`.

</details>

<details>
<summary>How are percentages calculated?</summary>

Each percentage is `count / total counted values * 100`. If blanks are skipped,
they are not part of the denominator; if blanks are included, `(empty)` counts
like any other value.

</details>

<details>
<summary>Is my CSV uploaded?</summary>

No. Parsing and counting happen in WebAssembly in your browser; the pasted table
never leaves your machine.

</details>

## Related tools

- [Base Decoder](https://gizza.ai/tools/base-decoder/): Auto-detect and decode Base16, Base32, Base45, Base58, Base64, and Base85 text, including nested layers, locally in your browser.
- [Before / after image slider generator](https://gizza.ai/tools/before-after-slider/): Turn two images into an interactive before/after comparison slider: one self-contained HTML file with inline CSS + JS, no libraries.
- [BSON Inspector](https://gizza.ai/tools/bson-inspector/): Paste BSON bytes as base64 or hex and inspect a typed tree or canonical MongoDB Extended JSON v2 with ObjectId, dates, binary, and int64 preserved.
- [Preview a Bulk File Rename](https://gizza.ai/tools/bulk-file-renamer/): Preview old-to-new filename mappings with find/replace, regex, numbering, case conversion, prefix/suffix, and collision warnings.
- [Decode/Transform Recipe Pipeline](https://gizza.ai/tools/cyberchef-pipeline/): Chain byte-level decode/transform steps — Base64, hex, URL, gzip/zlib, XOR, ROT13 — into one recipe, applied top to bottom. Free, private, runs entirely in your browser.
