n8n has dedicated nodes for reading and writing file formats: **Extract From File** reads spreadsheets (XLSX, CSV), PDFs, and more into JSON items, while **C...
n8n has dedicated nodes for reading and writing file formats: Extract From File reads spreadsheets (XLSX, CSV), PDFs, and more into JSON items, while Convert to File does the reverse. Use these instead of writing custom parsing code -- they handle edge cases like encoding, sheet selection, and header detection automatically.
Real-world example: A Google Drive trigger detects a new XLSX file uploaded by a client. You need to read the spreadsheet, validate the data, and generate a PDF report.
Workflow structure:
[Google Drive Trigger] → [Extract From File] → [Code: Validate] → [Convert to File] → [Send Email]
(new .xlsx) (XLSX → JSON) (check rows) (JSON → CSV) (attach CSV)
```text
**Extract From File** node configuration:
| Setting | Value |
|-----------------|----------------|
| Operation | Extract From XLSX |
| Binary Property | `data` |
| Header Row | Enabled |
| Sheet Name | `Sheet1` |
```json
// Input: binary XLSX file with columns: Name, Email, Amount
// Output: JSON items
[
{ "Name": "Alice", "Email": "alice@co.com", "Amount": 1500 },
{ "Name": "Bob", "Email": "bob@co.com", "Amount": 3200 },
{ "Name": "Carol", "Email": "carol@co.com", "Amount": 750 }
]
```text
Validation Code node:
```javascript
const items = $input.all();
const valid = [];
const invalid = [];
for (const item of items) {
if (item.json.Email && item.json.Amount > 0) {
valid.push(item);
} else {
invalid.push({
json: { ...item.json, error: 'Missing email or invalid amount' }
});
}
}
// Send valid items downstream, log invalid separately
return valid;
```text
**Convert to File** node configuration for the output:
| Setting | Value |
|-------------------|-------------------|
| Operation | Convert to CSV |
| Binary Property | `report` |
| File Name | `validated_data.csv` |
The Send Email node then attaches the `report` binary property as `validated_data.csv`. The entire file transformation pipeline requires zero manual parsing code.
---
> **Summary: Summary**
>
> The most effective n8n data transformation workflows combine the right node type for each task: Edit Fields for renaming, Merge for joining, Split Out and Aggregate for reshaping cardinality, Code nodes only for genuine programming logic, and binary nodes for file format conversion. Defensive fallback expressions and consistent date handling via Luxon round out a robust data transformation toolkit.
**Related:** [Flatten Deeply Nested API Responses](../code-node-mastery/01-flatten-deeply-nested-api-responses.md) | [Use the HTTP Request Node as a Universal Connector](../integration-patterns/01-use-the-http-request-node-as-a-universal-connector.md)
I build production n8n and Cloudflare automation for teams — the same engineering behind HarperFlow. Fixed-price, escrow-protected, US-based.