# Field Extractor

Extract columns or character ranges from every line of text. 1-based selectors with negative indices, ranges, reordering, custom delimiters. A browser cut/awk, no upload.

## Run it

- **CLI:** `gizza tool field-extractor "alice 30 engineer
bob 25 designer
carol 41 writer" 'selectors=1,3  or  2-4  or  -1'`
- **Web:** https://gizza.ai/tools/field-extractor/
- **Agents:** machine-readable descriptor (parameters JSON Schema) at https://gizza.ai/tools/field-extractor/tool.json

## Inputs

- `text` — Input text _(field)_
- `mode` — Mode _(field)_
- `selectors` — Selectors _(field)_
- `delimiter` — Delimiter (blank = whitespace) _(field)_
- `output_delimiter` — Output delimiter (blank = same) _(field)_
- `trim` — Trim each field _(field)_
- `skip_empty_lines` — Skip empty lines _(field)_
- `skip_header` — Skip header row _(field)_

## Output

- Extracted text (text)

## Query parameters

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

- `text` — Input text
- `mode` — Mode
- `selectors` — Selectors
- `delimiter` — Delimiter (blank = whitespace)
- `output_delimiter` — Output delimiter (blank = same)
- `trim` — Trim each field
- `skip_empty_lines` — Skip empty lines
- `skip_header` — Skip header row

Example: `https://gizza.ai/tools/field-extractor/?text=alice%2030%20engineer%0Abob%2025%20designer%0Acarol%2041%20writer&mode=fields&selectors=1%2C3%20%20or%20%202-4%20%20or%20%20-1&delimiter=blank%2C%20comma%2C%20%7C%2C%20%3A%3A%2C%20%5Ct&output_delimiter=blank%2C%20comma%2C%20%5Ct%2C%20newline&trim=true&skip_empty_lines=true&skip_header=true`

---

## About this field extractor

This tool pulls specific columns or character ranges out of every line of text —
think of it as a friendly, browser-local version of the Unix `cut` and `awk`
column tricks, with no files to upload and no command line to remember.

Paste your text, pick **Fields** or **Characters**, and describe what you want
with 1-based selectors:

```
alice 30 engineer
bob 25 designer
carol 41 writer
```

Selecting fields `1,3` with a blank delimiter (whitespace) gives:

```
alice engineer
bob designer
carol writer
```

### Selector syntax

- **Single columns**: `1`, `3` (1-based, counted from the left).
- **Negative indices**: `-1` is the last field, `-2` the second-to-last — no
  need to know how many columns each line has.
- **Ranges**: `2-4` takes fields 2, 3 and 4. `4-2` reverses them.
- **Open-ended ranges**: `3-` takes field 3 through the end (like `cut`).
- **Reordering**: selectors emit in the order you write them, so `3,1,2` moves
  column 3 to the front.
- Endpoints can be negative too: `-3--1` is the last three fields, `-2-` is the
  last two.

### Delimiters

Leave **Delimiter** blank to split on runs of whitespace (tabs and multiple
spaces collapse, like awk). Otherwise type any delimiter: a comma, a pipe `|`, a
multi-character string like `::`, a keyword (`tab`, `comma`, `pipe`,
`semicolon`, `colon`, `space`), or an escape (`\t`, `\n`).

The **output delimiter** controls how the extracted pieces are joined. Blank
reuses the input delimiter; set it to `\t`, a comma, or the keyword `newline` to
put each extracted piece on its own line.

### Character mode

Switch to **Characters** to cut by character position instead of by column —
useful for fixed-width codes and IDs. `1-4` keeps the first four characters of
every line. Character mode counts Unicode code points, so accented letters and
emoji are never split in half.

### Options and limits

- An explicitly numbered single field that is out of range emits an empty
  string (matching `cut`); a range simply stops at the last available field.
- **Trim** removes surrounding whitespace from each extracted field.
- **Skip empty lines** drops blank or whitespace-only lines from the output.
- **Skip header row** ignores the first line before extracting.
- This is a simple splitter, not an RFC-4180 CSV parser: it does not understand
  quoted fields that contain the delimiter. For quoted CSV, use the dedicated
  CSV tools instead.

Everything runs locally in your browser. Your text is never uploaded.

### FAQ

<details>
<summary>How do I get the last column when rows have different widths?</summary>

Use `-1` as the selector. Negative indices count from the end of each line, so
`-1` is always the last field and `-2` the second-to-last, regardless of how
many columns a given row has.

</details>

<details>
<summary>What does a blank delimiter do?</summary>

A blank delimiter splits on runs of whitespace and collapses them, exactly like
awk's default field splitting. So `a    b\tc` becomes three fields. Type a
specific delimiter (comma, `|`, `::`, `\t`, …) to split on that instead.

</details>

<details>
<summary>Can I reorder or reverse columns?</summary>

Yes. Selectors emit in the order you write them, so `3,1,2` puts column 3 first.
A descending range like `4-1` reverses fields 1 through 4.

</details>

<details>
<summary>How is character mode different from field mode?</summary>

Field mode splits each line into columns by a delimiter and selects whole
columns. Character mode ignores delimiters and selects by character position, so
`1-4` keeps the first four characters of every line — handy for fixed-width IDs.
It is Unicode-safe and never splits a multi-byte character.

</details>

<details>
<summary>Does it handle quoted CSV fields?</summary>

No. This is a plain splitter, like `cut -d`, so a comma inside a quoted field is
treated as a separator. For proper RFC-4180 CSV with quoted fields, use the
dedicated CSV column tools.

</details>

## Related tools

- [Extract Action Items from Meeting Notes](https://gizza.ai/tools/action-item-extractor/): Extract action items, owners, and decisions from meeting notes or daily notes with deterministic rules. Markdown checklist or JSON, private in-browser.
- [Add Line Numbers](https://gizza.ai/tools/add-line-numbers/): Add line numbers to every line of text online, like nl or cat -n — custom start, step, separator, and alignment. Free and private, runs in your browser.
- [ANSI Log Renderer](https://gizza.ai/tools/ansi-log-renderer/): Paste ANSI-colored terminal output or CI logs and render them as HTML, or strip escape codes to plain text. Handles 16-color, 256-color, and truecolor SGR codes.
- [Rust AST Diff](https://gizza.ai/tools/ast-diff/): Compare two Rust source snippets structurally. The tool parses both files, canonicalizes their ASTs, and ignores formatting, whitespace, and comments.
- [Bulk Artifact Extractor](https://gizza.ai/tools/bulk-artifact-extractor/): Scan pasted text for emails, URLs, IPs, domains, phones, Bitcoin addresses, and Luhn-valid card numbers with offsets and context.
