从文件提取#
¥Extract From File
n8n 工作流中的常见模式是接收文件,文件来源可以是 HTTP 请求节点(从网站获取的文件)、Webhook 节点(从其他地方发送到工作流的文件)或本地源。以这种方式获取的数据通常为二进制格式,例如电子表格或 PDF 文件。
¥A common pattern in n8n workflows is to receive a file, either from an 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.
“从文件提取”节点从二进制格式文件中提取数据并将其转换为 JSON 格式,以便工作流的其余部分可以轻松操作 JSON 数据。要将 JSON 转换回二进制文件类型,请参阅 转换为文件 节点。
¥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 node.
操作#
¥Operations
使用“操作”下拉菜单选择要从中提取数据的源文件格式。
¥Use the Operations drop-down to select the format of the source file to extract data from.
- 从 CSV 文件提取:"逗号分隔值" 文件类型通常用于表格数据。
¥Extract From CSV: The "Comma Separated Values" file type is commonly used for tabulated data.
- 从 HTML 文件提取:从标准网页 HTML 格式文件中提取字段。
¥Extract From HTML: Extract fields from standard web page HTML format files.
- 从 JSON 文件提取:从二进制文件中提取 JSON 数据。
¥Extract From JSON: Extract JSON data from a binary file.
- 从 ICS 文件提取:从 iCalendar 格式文件中提取字段。
¥Extract From ICS: Extract fields from iCalendar format files.
- 从 ODS 文件提取:从 ODS 电子表格文件中提取字段。
¥Extract From ODS: Extract fields from ODS spreadsheet files.
- 从 PDF 文件提取:从可移植文档格式 (PDF) 文件中提取字段。
¥Extract From PDF: Extract fields from Portable Document Format files.
- 从 RTF 文件提取:从富文本格式 (RTF) 文件中提取字段。
¥Extract From RTF: Extract fields from Rich Text Format files.
- 从文本文件提取:从标准文本文件格式中提取字段。
¥Extract From Text File: Extract fields from a standard text file format.
- 从 XLS 文件提取:从 Microsoft Excel 文件(旧格式)中提取字段。
¥Extract From XLS: Extract fields from a Microsoft Excel file (older format).
- 从 XLSX 文件提取:从 Microsoft Excel 文件中提取字段。
¥Extract From XLSX: Extract fields from a Microsoft Excel file.
- 将文件转换为 Base64 字符串:将二进制数据转换为易于阅读的 base64 格式
¥Move File to Base64 String: Converts binary data to a text-friendly base64 format.
示例工作流程#
¥Example workflow
本示例中使用 Webhook 节点来触发工作流。当 CSV 文件发送到 webhook 地址时,文件数据将由“从文件提取”节点输出和接收。
¥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.
Workflow preview placeholder.
设置为以 '从 CSV 文件提取:' 模式运行,节点将以一系列 JSON 'row' 对象的形式输出数据:
¥Set to operate as 'Extract from CSV', the node then outputs the data as a series of JSON 'row' objects:
1 2 3 4 5 6 7 8 | |
Receiving files with a webhook
选择 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
输入节点输入数据中包含二进制文件的字段名称。默认值为 'data'。
¥Enter the name of the field from the node input data that contains the binary file. The default is 'data'.
目标输出字段#
¥Destination Output Field
输入节点输出中用于存储提取数据的字段名称。
¥Enter the name of the field in the node output that will contain the extracted data.
此参数仅适用于以下操作:
¥This parameter is only available for these operations:
- 从 JSON 文件提取:
¥Extract From JSON
- 从 ICS 文件提取:
¥Extract From ICS
- 从文本文件提取:
¥Extract From Text File
- 将文件转换为 Base64 字符串
¥Move File to Base64 String
模板和示例#
¥Templates and examples