Class: CSVLoader
document_loaders/fs/csv.CSVLoader
Loads a CSV file into a list of documents. Each document represents one row of the CSV file.
When column
is not specified, each row is converted into a key/value pair
with each key/value pair outputted to a new line in the document's pageContent.
Example
// CSV file: // id,html // 1,Corruption discovered at the core of the Banking Clan! // 2,Corruption discovered at the core of the Banking Clan!
const loader = new CSVLoader("path/to/file.csv"); const docs = await loader.load();
// docs[0].pageContent: // id: 1 // html: Corruption discovered at the core of the Banking Clan!
When column
is specified, one document is created for each row, and the
value of the specified column is used as the document's pageContent.
Example
// CSV file:
// id,html
// 1,<i>Corruption discovered at the core of the Banking Clan!</i>
// 2,<i>Corruption discovered at the core of the Banking Clan!</i>
const loader = new CSVLoader("path/to/file.csv", "html");
const docs = await loader.load();
// docs[0].pageContent:
// <i>Corruption discovered at the core of the Banking Clan!</i>
Hierarchy
↳
CSVLoader
Constructors
constructor
• new CSVLoader(filePathOrBlob
, column?
)
Parameters
Name | Type |
---|---|
filePathOrBlob | string | Blob |
column? | string |
Overrides
Defined in
langchain/src/document_loaders/fs/csv.ts:39
Properties
column
• Optional
column: string
Defined in
langchain/src/document_loaders/fs/csv.ts:39
filePathOrBlob
• filePathOrBlob: string
| Blob
Inherited from
Defined in
langchain/src/document_loaders/fs/text.ts:7
Methods
load
▸ load(): Promise
<Document
<Record
<string
, any
>>[]>
Returns
Promise
<Document
<Record
<string
, any
>>[]>
Inherited from
Defined in
langchain/src/document_loaders/fs/text.ts:15
loadAndSplit
▸ loadAndSplit(splitter?
): Promise
<Document
<Record
<string
, any
>>[]>
Parameters
Name | Type |
---|---|
splitter | TextSplitter |
Returns
Promise
<Document
<Record
<string
, any
>>[]>
Inherited from
Defined in
langchain/src/document_loaders/base.ts:15
parse
▸ Protected
parse(raw
): Promise
<string
[]>
Parameters
Name | Type |
---|---|
raw | string |
Returns
Promise
<string
[]>
Overrides
Defined in
langchain/src/document_loaders/fs/csv.ts:43
imports
▸ Static
imports(): Promise
<{ readFile
: (path
: PathLike
| FileHandle
, options?
: null
| {} & Abortable
) => Promise
<Buffer
>(path
: PathLike
| FileHandle
, options
: {} & Abortable
| BufferEncoding
) => Promise
<string
>(path
: PathLike
| FileHandle
, options?
: null
| BufferEncoding
| ObjectEncodingOptions
& Abortable
& {}) => Promise
<string
| Buffer
> }>
Returns
Promise
<{ readFile
: (path
: PathLike
| FileHandle
, options?
: null
| {} & Abortable
) => Promise
<Buffer
>(path
: PathLike
| FileHandle
, options
: {} & Abortable
| BufferEncoding
) => Promise
<string
>(path
: PathLike
| FileHandle
, options?
: null
| BufferEncoding
| ObjectEncodingOptions
& Abortable
& {}) => Promise
<string
| Buffer
> }>
Inherited from
Defined in
langchain/src/document_loaders/fs/text.ts:49