Doc 1343/improvements (#2908)

Co-authored-by: Justin Ellingwood <justin@n8n.io>
This commit is contained in:
Nick Veitch
2025-02-27 10:58:16 +00:00
committed by GitHub
parent 5715ecf925
commit c85fa2b7a2
5 changed files with 118 additions and 47 deletions

View File

@@ -1,6 +0,0 @@
/// note | In version 1.9.0 n8n changed the templating language for expressions
If you have issues with expressions in 1.9.0:
* Please report the issue on the [forums](https://community.n8n.io/){:target=_blank .external-link}.
* Self-hosted users can switch back to RiotTmpl: set `N8N_EXPRESSION_EVALUATOR` to `tmpl`. Refer to [Environment variables](/hosting/configuration/environment-variables/index.md) for more information on configuring self-hosted n8n.
///

View File

@@ -0,0 +1,62 @@
{
"name": "Extract from file example",
"nodes": [
{
"parameters": {
"httpMethod": "POST",
"path": "06696ea7-9dc7-464a-873b-3feb095b0874",
"options": {
"rawBody": true
}
},
"type": "n8n-nodes-base.webhook",
"typeVersion": 2,
"position": [
-380,
-80
],
"id": "dfbd51af-6050-47c5-a26c-74cba77f65f7",
"name": "Webhook",
"webhookId": "06696ea7-9dc7-464a-873b-3feb095b0874"
},
{
"parameters": {
"options": {
"headerRow": false
}
},
"type": "n8n-nodes-base.extractFromFile",
"typeVersion": 1,
"position": [
-160,
-80
],
"id": "1b1e4643-8269-402b-83af-dfd90fd6a0b5",
"name": "Extract from File"
}
],
"pinData": {},
"connections": {
"Webhook": {
"main": [
[
{
"node": "Extract from File",
"type": "main",
"index": 0
}
]
]
}
},
"active": true,
"settings": {
"executionOrder": "v1"
},
"versionId": "dd2bf7f1-692a-41a8-9c2e-7931de57fa13",
"meta": {
"instanceId": "1060f46e51fc7902c377ab29d7cbfb87696ddf6b3c5c27cbbb65c3cb36e21baf"
},
"id": "9i3iDZf5MpjlJ2sh",
"tags": []
}

View File

@@ -5,31 +5,26 @@ contentType: howto
# Expressions
--8<-- "_snippets/code/tournament-notes.md"
Expressions are a powerful feature implemented in all n8n nodes. They allow node parameters to be set dynamically based on data from:
Use [expressions](/glossary.md#expression-n8n) to set node parameters dynamically based on data from:
- Previous nodes
- Previous node executions
- The workflow
- Your n8n environment
You can execute JavaScript within an expression.
You can also execute JavaScript within an expression, making this a convenient and easy way to manipulate data into useful parameter values without writing extensive extra code.
n8n created and uses a templating language called [Tournament](https://github.com/n8n-io/tournament){:target=_blank .external-link}, and extends it with [custom methods and variables](/code/builtin/overview.md) and [data transformation functions](/code/builtin/data-transformation-functions/index.md) that help with common tasks, such as retrieving data from other nodes, or accessing metadata.
n8n created and uses a templating language called [Tournament](https://github.com/n8n-io/tournament){:target=_blank .external-link}, and extends it with [custom methods and variables](/code/builtin/overview.md) and [data transformation functions](/code/builtin/data-transformation-functions/index.md). These features make it easier to perform common tasks like getting data from other nodes or accessing workflow metadata.
n8n supports two libraries:
n8n additionally supports two libraries:
- [Luxon](https://github.com/moment/luxon/){:target=_blank .external-link}, for working with data and time.
- [Luxon](https://github.com/moment/luxon/){:target=_blank .external-link}, for working with dates and time.
- [JMESPath](https://jmespath.org/){:target=_blank .external-link}, for querying JSON.
/// note | No Python support
Expressions must use JavaScript.
///
/// note | Data in n8n
When writing expressions, it's helpful to understand data structure and behavior in n8n. Refer to [Data](/data/index.md) for more information on working with data in your workflows.
///
## Writing expressions
## Writing expressions
To use an expression to set a parameter value:
@@ -81,11 +76,10 @@ This expression:
An expression contains one line of JavaScript. This means you cannot do things like variable assignments or multiple standalone operations.
To understand the limitations of JavaScript in expressions, and start thinking about workarounds, look at the following two pieces of code. Both code examples use the Luxon date and time library to find the time between two dates in months, and encloses the code in handlebar brackets, like an expression.
To understand the limitations of JavaScript in expressions, and start thinking about workarounds, look at the following two pieces of code. Both code examples use the Luxon date and time library to find the time between two dates in months, and encloses the code in handlebar brackets, like an expression.
However, the first example isn't a valid n8n expression:
```js
// This example is split over multiple lines for readability
// It's still invalid when formatted as a single line
@@ -100,10 +94,8 @@ However, the first example isn't a valid n8n expression:
}}
```
While the second example is valid:
```js
{{DateTime.fromISO('2017-03-13').diff(DateTime.fromISO('2017-02-13'), 'months').toObject()}}
```

View File

@@ -8,31 +8,54 @@ priority: high
# Extract From File
Use the Extract From File node to get data from a binary format and convert it to JSON.
A common pattern in n8n workflows is to receive a file, either from and [HTTP Request node][] (for files you are fetching from a website), a [Webhook Node][] (for files which are sent to your workflow from elsewhere), or from a local source. Data obtained in this way is often in a binary format, for example a spreadsheet or PDF.
/// note | Convert to File
To convert JSON data to a file format, use the [Convert to File](/integrations/builtin/core-nodes/n8n-nodes-base.converttofile.md) node.
///
The Extract From File node extracts data from a binary format file and converts it to JSON, which can then be easily manipulated by the rest of your workflow. For converting JSON back into a binary file type, please see the [Convert to File](/integrations/builtin/core-nodes/n8n-nodes-base.converttofile.md) node.
## Operations
* Extract From CSV
* Extract From HTML
* Extract From JSON
* Extract From ICS
* Extract From ODS
* Extract From PDF
* Extract From RTF
* Extract From Text File
* Extract From XLS
* Extract From XLSX
* Move File to Base64 String
Use the **Operations** drop-down to select the format of the source file to extract data from.
- **Extract From CSV**: The "Comma Separated Values" file type is commonly used for tabulated data.
- **Extract From HTML**: Extract fields from standard web page HTML format files.
- **Extract From JSON**: Extract JSON data from a binary file.
- **Extract From ICS**: Extract fields from iCalendar format files.
- **Extract From ODS**: Extract fields from ODS spreadsheet files.
- **Extract From PDF**: Extract fields from Porrtable Document Format files.
- **Extract From RTF**: Extract fields from Rich Text Format files.
- **Extract From Text File**: Extract fields from a standard text file format.
- **Extract From XLS**: Extract fields from a Microsoft Excel file (older format).
- **Extract From XLSX**: Extract fields from a Microsoft Excel file.
- **Move File to Base64 String**: Converts binary data to a text-friendly [base64][] format.
## Example workflow
In this example, a Webhook node is used to trigger the workflow. When a CSV file is sent to the webhook address, the file data is output and received by the Extract From File node.
[[ workflowDemo("file:///integrations/builtin/core-nodes/n8n-nodes-base.extractfromfile/webhook-example.json") ]]
Set to operate as 'Extract from CSV', the node then outputs the data as a series of JSON 'row' objects:
```
{
"row": {
"0": "apple",
"1": "1",
"2": "2",
"3": "3"
}
...
```
/// tip | Receiving files with a webhook
Select the Webhook Node's **Add Options** button and select **Raw body**, then enable that setting to get the node to output the binary file that the subsequent node is expecting.
///
## Node parameters
### Input Binary Field
Enter the name of the field in the node input data that contains the binary file.
Enter the name of the field from the node input data that contains the binary file. The default is 'data'.
### Destination Output Field
@@ -40,12 +63,16 @@ Enter the name of the field in the node output that will contain the extracted d
This parameter is only available for these operations:
* Extract From JSON
* Extract From ICS
* Extract From Text File
* Move File to Base64 String
- Extract From JSON
- Extract From ICS
- Extract From Text File
- Move File to Base64 String
## Templates and examples
<!-- see https://www.notion.so/n8n/Pull-in-templates-for-the-integrations-pages-37c716837b804d30a33b47475f6e3780 -->
[[ templatesWidget(page.title, 'extract-from-file') ]]
[HTTP Request Node]: /integrations/builtin/core-nodes/n8n-nodes-base.httprequest/index.md
[Webhook Node]: /integrations/builtin/core-nodes/n8n-nodes-base.webhook/index.md
[base64]: https://datatracker.ietf.org/doc/html/rfc4648#section-4

View File

@@ -1756,7 +1756,7 @@ This release adds the HTTP request tool. You can use it with an AI agent as a to
[ekadin-mtc](https://github.com/ekadin-mtc){:target=_blank .external-link}
[Eric Francis](https://github.com/EricFrancis12){:target=_blank .external-link}
[Josh Sorenson](https://github.com/joshsorenson){:target=_blank .external-link}
[Mohammad Alsmadi](https://github.com/smadixd){:target=_blank .external-link}
Mohammad Alsmadi
[Nikolai T. Jensen](https://github.com/ch0wm3in){:target=_blank .external-link}
[n8n-ninja](https://github.com/n8n-ninja){:target=_blank .external-link}
[pebosi](https://github.com/pebosi){:target=_blank .external-link}
@@ -3345,8 +3345,6 @@ Read more:
* This is a beta release, and not yet available in the main product. Follow the instructions in [Access LangChain in n8n](/advanced-ai/langchain/overview.md) to try it out. Self-hosted and Cloud options are available.
* Learn how LangChain concepts map to n8n nodes in [LangChain concepts in n8n](/advanced-ai/langchain/langchain-n8n.md).
* Browse n8n's new [Cluster nodes](/integrations/builtin/cluster-nodes/index.md). This is a new set of node types that allows for multiple nodes to work together to configure each other.
* If you want to take a look at the code, it's available on the [ai-beta](https://github.com/n8n-io/n8n/tree/ai-beta){:target=_blank .external-link} in the n8n repository. Note that it may move in the future.
## n8n@1.9.0
@@ -3356,8 +3354,6 @@ View the [commits](https://github.com/n8n-io/n8n/compare/n8n@1.8.2...n8n@1.9.0){
This release contains new features, performance improvements, and bug fixes.
--8<-- "_snippets/code/tournament-notes.md"
<div class="n8n-new-features" markdown>
#### Tournament