# Extract from File

> Read rows or text out of a CSV, TSV, Excel (.xlsx), PDF, JSON, JSON Lines, or plain-text file.

Read structured records or text out of a CSV, Excel, PDF, JSON, or text file for downstream Steps. Use **Extract from File** (`extractFromFile`) with files in [File Management](https://docs.getglow.ai/manage/workspace-settings/file-management), [Form Trigger](https://docs.getglow.ai/build/triggers/form-trigger) uploads, [Convert to File](https://docs.getglow.ai/build/action-steps/convert-to-file) outputs, or [HTTP Request](https://docs.getglow.ai/build/action-steps/http-request) downloads.

**At a glance**

- **Use it to:** Parse rows, columns, or text out of a CSV, TSV, XLSX, PDF, JSON, JSONL, or text file
- **Find it:** Tools → Data → Convert → Extract from File
- **Cost:** 5 Step credits per started 10 MB
- **Limits:** 20 MiB max file · 100,000 max rows · 500,000 max characters · 1,000 max PDF pages
- **Output:** {{ N.results }}, {{ N.resultCount }}, {{ N.headers }} (tabular/JSON) or {{ N.text }}, {{ N.pages }} (PDF/text)
- **Instead:** Parse JSON (when the content is already a JSON string rather than a file)

## Setting it up

### Add Extract from File

Open **Tools → Data → Convert** in the dock and select **Extract from File**.

### Choose the file and file type

- **File** (`file`): Pick a workspace file or map a file reference from an earlier Step (`{{ 1.formData.attachment }}` or `{{ 2.ret }}`).
- **File type** (`operation`): Keep **Work it out from the file** (`"auto"`, default) to detect the format automatically, or pick one:
  - **CSV or TSV** (`"csv"`).
  - **Excel (.xlsx)** (`"xlsx"`, supports `.xlsx` and `.xlsm`; legacy `.xls` files are refused).
  - **PDF** (`"pdf"`, extracts embedded text from text-layer PDFs).
  - **JSON or JSON Lines** (`"json"`, supports `.json`, `.jsonl`, and `.ndjson`).
  - **Text** (`"text"`, UTF-8 plain text, Markdown, log, or XML files).

### Configure format options (optional)

Under **Optional Props**, refine how tabular files are parsed:

| Option                               | Applies to      | What it does                                                                                                                                               |
| :----------------------------------- | :-------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **First row holds the column names** | CSV/TSV, Excel  | Enabled by default (`headerRow: true`), turning each row into a named record (`{"email": "ada@example.com"}`). Disable to get `column_1`, `column_2` keys. |
| **Separator** (`delimiter`)          | CSV/TSV         | **Automatic** (`auto`, default), **Comma**, **Semicolon**, **Tab**, or **Pipe**.                                                                           |
| **Sheet** (`sheetName`)              | Excel (`.xlsx`) | Name of the worksheet tab to read. Leave blank to read the first sheet in the workbook.                                                                    |

## What it passes on

The output fields depend on the extracted format (assuming **Extract from File** is Step 2):

| Format                | Output references                                                                                                                                           |
| :-------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **CSV / TSV**         | `{{ 2.results }}` (list of row records), `{{ 2.resultCount }}`, `{{ 2.headers }}` (column names), and `{{ 2.format }}` (`"csv"`).                           |
| **Excel (`.xlsx`)**   | `{{ 2.results }}`, `{{ 2.resultCount }}`, `{{ 2.headers }}`, `{{ 2.sheetName }}`, `{{ 2.sheetNames }}` (all tabs in the workbook), and `{{ 2.format }}`.    |
| **JSON / JSON Lines** | `{{ 2.results }}` (array of items or `[object]`), `{{ 2.resultCount }}`, `{{ 2.data }}` (when the file root is a single JSON object), and `{{ 2.format }}`. |
| **PDF**               | `{{ 2.text }}` (combined document text), `{{ 2.pageCount }}`, `{{ 2.pages }}` (`[{ pageNumber, text }]`), and `{{ 2.format }}` (`"pdf"`).                   |
| **Text**              | `{{ 2.text }}` and `{{ 2.format }}` (`"text"`).                                                                                                             |

> **Scanned PDFs:** **Extract from File** reads embedded text layers from PDF
> files. For scanned image PDFs with no selectable text, pass the file to an [AI
> Prompt](https://docs.getglow.ai/build/ai-features/ai-prompt) Step for OCR. Password-protected PDFs
> are refused.

## Limits

| Resource                    | Limit                                                       |
| :-------------------------- | :---------------------------------------------------------- |
| **Maximum input file size** | **20 MiB** (`20,971,520` bytes)                             |
| **Maximum extracted rows**  | **100,000** rows (`CSV`, `TSV`, `XLSX`, `JSON`, or `JSONL`) |
| **Maximum extracted text**  | **500,000** characters (`PDF` or `Text`)                    |
| **Maximum PDF page count**  | **1,000** pages                                             |

## Examples to copy

  

**Import rows from an uploaded CSV**

    Parse a CSV uploaded through a [Form Trigger](https://docs.getglow.ai/build/triggers/form-trigger) and filter for active rows:

    1. Add **Form Trigger** at Step 1 with a **File upload** field named `csv_file`.
    2. Add **Extract from File** at Step 2 with **File** set to `{{ 1.formData.csv_file }}` and **File type** set to **CSV or TSV**.
    3. Add a [Filter](https://docs.getglow.ai/build/action-steps/filter-items) Step at Step 3 over `{{ 2.results }}` where `{{ $item.status }}` is `"active"`.

  

  

**Read an invoice PDF**

    Download a PDF statement with [HTTP Request](https://docs.getglow.ai/build/action-steps/http-request), extract its text, and summarize it:

    1. Fetch the PDF in Step 2 using **HTTP Request**.
    2. Add **Extract from File** at Step 3 with **File** set to `{{ 2.ret }}` and **File type** set to **PDF**.
    3. Pass `{{ 3.text }}` into an [AI Prompt](https://docs.getglow.ai/build/ai-features/ai-prompt) Step at Step 4 to extract the invoice number and total.

  

**Verify it works**

- **Run:** Pick a sample file in File, leave File type on Work it out from the file, and click Run step
- **You should see:** Executions displays the extracted {{ N.results }} rows (with {{ N.resultCount }} and {{ N.headers }}) for tabular files, or {{ N.text }} for PDF and text files.

## What's Next?

- Turn a list of records or text into a downloadable file with [Convert to File](https://docs.getglow.ai/build/action-steps/convert-to-file).
- Filter, sort, or deduplicate the extracted `results` list with [Filter](https://docs.getglow.ai/build/action-steps/filter-items), [Sort](https://docs.getglow.ai/build/action-steps/sort), or [Remove Duplicates](https://docs.getglow.ai/build/action-steps/remove-duplicates).
