npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

n8n-nodes-local-data-extract

v1.0.0

Published

n8n node to extract data from local files (CSV, Excel, JSON, TXT)

Readme

local-data-extract

📋 目录

🔍 插件概述

Local Data Extract 是一个 N8N 节点插件,用于从本地文件系统读取和解析多种格式的数据文件。这个插件提供了灵活的数据提取选项,支持多种文件格式,并允许用户自定义数据处理方式。

✨ 特性

  • 支持多种文件格式: CSV, TXT, Excel (XLS/XLSX), JSON
  • 灵活的文件路径配置(绝对路径或相对路径)
  • 自动检测文件编码
  • 对 CSV 和 TXT 文件支持自定义分隔符
  • 对 Excel 文件支持多工作表读取和表头配置
  • 对 JSON 文件支持路径提取和对象扁平化
  • 支持添加自定义字段
  • 支持字段类型转换
  • 支持字段重新排序

📦 安装

通过 NPM 安装

# 在 N8N 安装目录中运行
npm install local-data-extract

# 重启 N8N 服务
systemctl restart n8n  # 或使用你的 N8N 启动命令

通过 N8N 界面安装

  1. 打开 N8N 界面
  2. 点击左侧导航栏中的 "Settings"
  3. 选择 "Community Nodes"
  4. 输入 "local-data-extract" 并点击 "Install"
  5. 安装完成后,节点将出现在 "All Nodes" 列表中

开发模式安装

# 克隆仓库
git clone https://github.com/yourusername/local-data-extract.git
cd local-data-extract

# 安装依赖
npm install

# 构建插件
npm run build

# 链接到 N8N
npm link
cd ~/.n8n/nodes
npm link local-data-extract

# 重启 N8N

⚙️ 节点配置

基础配置

| 参数名称 | 类型 | 必填 | 描述 | |---------|------|------|------| | 文件路径 | 字符串 | 是 | 要读取的文件路径(绝对路径或相对路径) | | 文件类型 | 下拉菜单 | 是 | 文件类型:CSV、TXT、Excel、JSON |

CSV/TXT 配置

| 参数名称 | 类型 | 必填 | 默认值 | 描述 | |---------|------|------|-------|------| | 分隔符 | 字符串 | 否 | "," | 字段分隔符 | | 编码 | 下拉菜单 | 否 | "utf8" | 文件编码 | | 包含表头 | 布尔值 | 否 | true | 文件是否包含表头行 | | 引号字符 | 字符串 | 否 | '"' | 用于包围值的引号字符 | | 转义字符 | 字符串 | 否 | '\' | 用于转义特殊字符的字符 | | 自动检测分隔符 | 布尔值 | 否 | false | 是否自动检测分隔符 |

Excel 配置

| 参数名称 | 类型 | 必填 | 默认值 | 描述 | |---------|------|------|-------|------| | 工作表名称 | 字符串 | 否 | - | 要读取的工作表名称(留空则读取所有工作表) | | 表头行号 | 数字 | 否 | 1 | 表头所在行号 | | 数据开始行 | 数字 | 否 | 2 | 数据开始行号 | | 多行表头 | 数字 | 否 | 1 | 表头占用的行数 | | 多表处理模式 | 下拉菜单 | 否 | "separate" | "separate" (分别输出) 或 "combined" (合并输出) | | 包含表头 | 布尔值 | 否 | true | 是否包含表头 |

JSON 配置

| 参数名称 | 类型 | 必填 | 默认值 | 描述 | |---------|------|------|-------|------| | 键路径 | 字符串 | 否 | - | 要提取的数据路径,例如 "data.items[0]" | | 扁平化对象 | 布尔值 | 否 | false | 是否将嵌套对象扁平化为单级对象 |

高级配置

| 参数名称 | 类型 | 必填 | 默认值 | 描述 | |---------|------|------|-------|------| | 添加自定义字段 | 布尔值 | 否 | false | 是否添加自定义字段 | | 自定义字段 | 列表 | 否 | [] | 自定义字段配置 | | 字段排序 | 列表 | 否 | [] | 输出字段的排序顺序 | | 类型转换 | 对象 | 否 | {} | 字段类型转换配置 |

📊 支持的文件格式

  • CSV (Comma-Separated Values): 逗号分隔值文件
  • TXT: 文本文件,支持自定义分隔符
  • Excel: .xls 和 .xlsx 格式
  • JSON: JavaScript 对象表示法格式

🔧 使用示例

示例 1: 读取 CSV 文件

  1. 添加 Local Data Extract 节点到你的工作流
  2. 在基础配置中,设置文件路径为你的 CSV 文件路径
  3. 选择文件类型为 "CSV"
  4. 设置分隔符为 ","
  5. 启用 "包含表头" 选项
  6. 连接节点到其他节点,如循环或数据库写入节点

示例 2: 读取 Excel 文件中的特定工作表

  1. 添加 Local Data Extract 节点到你的工作流
  2. 在基础配置中,设置文件路径为你的 Excel 文件路径
  3. 选择文件类型为 "Excel"
  4. 在 Excel 配置中,输入工作表名称
  5. 设置表头行号为 1,数据开始行号为 2
  6. 连接节点到后续处理节点

示例 3: 读取 JSON 文件并提取特定路径

  1. 添加 Local Data Extract 节点到你的工作流
  2. 在基础配置中,设置文件路径为你的 JSON 文件路径
  3. 选择文件类型为 "JSON"
  4. 在 JSON 配置中,输入键路径,例如 "data.users"
  5. 启用 "扁平化对象" 选项
  6. 连接节点到数据处理或存储节点

📤 输出格式

节点的输出是一个包含解析数据的数组。每个数组元素代表文件中的一条记录。

对于 CSV/TXT 和 Excel 文件,如果启用了表头,输出将是对象数组,其中每个对象的键是表头,值是对应的单元格内容。如果未启用表头,输出将是对象数组,键为 "column_1", "column_2" 等。

对于 JSON 文件,如果指定了键路径,输出将是该路径下的数据。如果启用了扁平化,嵌套对象将被扁平化,键将使用下划线连接。

🔨 开发指南

环境设置

# 克隆仓库(假设你是贡献者)
git clone https://github.com/yourusername/local-data-extract.git
cd local-data-extract

# 安装依赖
npm install

构建插件

# 构建插件
npm run build

# 开发模式(监视文件变化)
npm run dev

本地测试

# 链接到 N8N
npm link
cd ~/.n8n/nodes
npm link local-data-extract

# 重启 N8N 服务
systemctl restart n8n  # 或使用你的 N8N 启动命令

👥 贡献

欢迎提交问题和拉取请求!请确保遵循项目的代码风格和贡献指南。

📝 许可证

该项目在 MIT 许可证下发布。详见 LICENSE 文件。