> ## Documentation Index
> Fetch the complete documentation index at: https://cndoc-langchain.site/llms.txt
> Use this file to discover all available pages before exploring further.

# 多个独立文件 - 集成

> 使用 LangChain JavaScript 与多个独立文件 - 文档加载器进行集成。

本示例介绍如何从多个文件路径加载数据。第二个参数是文件扩展名到加载器工厂的映射。每个文件将传递给匹配的加载器，生成的文档将拼接在一起。

示例文件：

```text theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
src/document_loaders/example_data/example/
├── example.txt
└── example.csv

src/document_loaders/example_data/example2/
├── example.json
└── example.jsonl
```

示例代码：

```typescript theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
import { MultiFileLoader } from "@langchain/classic/document_loaders/fs/multi_file";
import {
  JSONLoader,
  JSONLinesLoader,
} from "@langchain/classic/document_loaders/fs/json";
import { TextLoader } from "@langchain/classic/document_loaders/fs/text";
import { CSVLoader } from "@langchain/classic/document_loaders/fs/csv";

const loader = new MultiFileLoader(
  [
    "src/document_loaders/example_data/example/example.txt",
    "src/document_loaders/example_data/example/example.csv",
    "src/document_loaders/example_data/example2/example.json",
    "src/document_loaders/example_data/example2/example.jsonl",
  ],
  {
    ".json": (path) => new JSONLoader(path, "/texts"),
    ".jsonl": (path) => new JSONLinesLoader(path, "/html"),
    ".txt": (path) => new TextLoader(path),
    ".csv": (path) => new CSVLoader(path, "text"),
  }
);
const docs = await loader.load();
console.log({ docs });
```

***

<div className="source-links">
  <Callout icon="terminal-2">
    [连接这些文档](/use-these-docs) 到 Claude、VSCode 等，通过 MCP 获取实时答案。
  </Callout>

  <Callout icon="edit">
    [在 GitHub 上编辑此页面](https://github.com/langchain-ai/docs/edit/main/src/oss/javascript/integrations/document_loaders/file_loaders/multi_file.mdx) 或 [提交问题](https://github.com/langchain-ai/docs/issues/new/choose)。
  </Callout>
</div>
