TextLoader
Compatibility
Only available on Node.js.
This notebook provides a quick overview for getting started with
TextLoader document loaders. For
detailed documentation of all TextLoader features and configurations
head to the API
reference.
Overview
Integration details
| Class | Package | Compatibility | Local | PY support |
|---|---|---|---|---|
| TextLoader | langchain | Node-only | ✅ | ❌ |
Setup
To access TextLoader document loader you’ll need to install the
langchain package.
Installation
The LangChain TextLoader integration lives in the langchain package:
- npm
- yarn
- pnpm
npm i langchain
yarn add langchain
pnpm add langchain
Instantiation
Now we can instantiate our model object and load documents:
import { TextLoader } from "langchain/document_loaders/fs/text";
const loader = new TextLoader(
"../../../../../../examples/src/document_loaders/example_data/example.txt"
);
Load
const docs = await loader.load();
docs[0];
Document {
pageContent: 'Foo\nBar\nBaz\n\n',
metadata: {
source: '../../../../../../examples/src/document_loaders/example_data/example.txt'
},
id: undefined
}
console.log(docs[0].metadata);
{
source: '../../../../../../examples/src/document_loaders/example_data/example.txt'
}
API reference
For detailed documentation of all TextLoader features and configurations head to the API reference: https://api.js.langchain.com/classes/langchain.document_loaders_fs_text.TextLoader.html