nodes / builtin / datatransformation
Extract From File
Turn a file into items, with the format auto-detected
Turn a downloaded or picked file (CSV, JSON, XML, text or PDF) into workflow items.
What it does
Section titled “What it does”Extract From File reads the file attached to the incoming item and returns its contents as a list of items. What you get depends on the format:
- CSV: one item per row, keyed by the header row. Empty rows are skipped.
- JSON: an array gives one item per element; a single object gives one item; a plain value gives
{ "value": ... }. - XML: the whole document as one object. Attributes get an
@prefix and repeated elements become lists. - Text: one item per line, each as
{ "text": "..." }. - PDF: one item with the extracted
textandpageCount.
The file can come from an Http Request download (stored under $binary) or from Local File Read (name, type, content). Each incoming item is treated as its own file. Excel files (XLSX) are not supported.
With Format on Auto-detect, the node looks at the file’s type first (for example text/csv or application/pdf), then the file name’s extension (.csv, .json, .xml, .pdf, .txt), then the first characters of the content (%PDF, {, [ or <).
When to use it
Section titled “When to use it”- Read rows from a CSV or JSON file that an Http Request downloaded.
- Let someone pick a file with Local File Read and process each row or line.
- Get the text out of a PDF without caring about page settings. For per-page text or a custom output field, use PDF Parser instead.
- For CSV with a different delimiter or no header row, use the CSV node instead: this node always splits on commas and treats the first row as headers.
Inputs and settings
Section titled “Inputs and settings”| Setting | Type | What it does |
|---|---|---|
| Format | Choice | The file format to decode, or auto-detect it. Options: Auto-detect, CSV, JSON, XML, Text, PDF. Default: Auto-detect |
| Binary Field | Text | Which $binary key on the incoming item holds the file. Default: data |
Binary Field only matters for files from Http Request, which stores a download under data by default. Items without a binary are read from their content or text field instead.
From Local File Read, set Read as to Text for CSV, JSON, XML and text files, and to Data URL or Base64 for PDFs.
Outputs
Section titled “Outputs”-
Output
The output is always a list. CSV, JSON arrays and text files usually give many items, so the next node runs once per row or line. XML, PDF and single-object JSON give one item.
Dependencies and credentials
Section titled “Dependencies and credentials”None. This node needs no connection and has no slots for other nodes.
Example workflow
Section titled “Example workflow”- An Http Request downloads
https://example.com/prices.csv. - Extract From File with Format on Auto-detect turns it into one item per row.
- Filter keeps rows where
{{ $input.stock }}is0. - Slack posts the out-of-stock products.
Common issues
Section titled “Common issues”- “Could not detect the file format. Set the Format field manually (CSV, JSON, XML, Text or PDF).” The file had no useful type, extension or recognisable start. Choose the format in Format.
- “No file to extract. Attach a binary under $binary, or provide a file from Local File Read.” The incoming item has no file under Binary Field and no
contentortextfield. Check the key name, or connect the node that produced the file. - “Could not parse JSON: …” The file is not valid JSON, or auto-detect guessed JSON wrongly. Fix the file or pick the right Format.
- “Field “data” could not be decoded as base64 PDF data.“ A PDF was read as Text by Local File Read. Set Read as to Data URL.
- A
.tsvfile comes out as one column. Tab-separated files are detected as CSV but split on commas. Use the CSV node with a tab delimiter.
Related nodes
Section titled “Related nodes”- PDF Parser: PDF text with per-page options.
- CSV: CSV with custom delimiters, or writing CSV.
- XML: convert XML text to JSON and back.
- Local File Read: let the user pick a file.