> ## Documentation Index
> Fetch the complete documentation index at: https://langchain-5e9cc07a-preview-opensw-1772748614-696205f.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# CSV integration

> Integrate with the CSV document loader using LangChain JavaScript.

<Tip>
  **Compatibility**: Only available on Node.js.
</Tip>

This notebook provides a quick overview for getting started with `CSVLoader` [document loaders](/oss/javascript/integrations/document_loaders). For detailed documentation of all `CSVLoader` features and configurations head to the [API reference](https://api.js.langchain.com/classes/langchain_community_document_loaders_fs_csv.CSVLoader.html).

This example goes over how to load data from CSV files. The second argument is the `column` name to extract from the CSV file. One document will be created for each row in 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`. 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`.

## Overview

### Integration details

| Class                                                                                                        | Package                                                                                                       | Compatibility | Local | [PY support](https://python.langchain.com/docs/integrations/document_loaders/csv) |
| :----------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------ | :-----------: | :---: | :-------------------------------------------------------------------------------: |
| [CSVLoader](https://api.js.langchain.com/classes/langchain_community_document_loaders_fs_csv.CSVLoader.html) | [@langchain/community](https://api.js.langchain.com/modules/langchain_community_document_loaders_fs_csv.html) |   Node-only   |   ✅   |                                         ✅                                         |

## Setup

To access `CSVLoader` document loader you'll need to install the `@langchain/community` integration, along with the `d3-dsv@2` peer dependency.

### Installation

The LangChain CSVLoader integration lives in the `@langchain/community` integration package.

<CodeGroup>
  ```bash npm theme={null}
  npm install @langchain/community @langchain/core d3-dsv@2
  ```

  ```bash yarn theme={null}
  yarn add @langchain/community @langchain/core d3-dsv@2
  ```

  ```bash pnpm theme={null}
  pnpm add @langchain/community @langchain/core d3-dsv@2
  ```
</CodeGroup>

## Instantiation

Now we can instantiate our model object and load documents:

```typescript theme={null}
import { CSVLoader } from "@langchain/community/document_loaders/fs/csv"

const exampleCsvPath = "../../../../../../langchain/src/document_loaders/tests/example_data/example_separator.csv";

const loader = new CSVLoader(exampleCsvPath)
```

## Load

```typescript theme={null}
const docs = await loader.load()
docs[0]
```

```javascript theme={null}
Document {
  pageContent: 'id｜html: 1｜"<i>Corruption discovered at the core of the Banking Clan!</i>"',
  metadata: {
    source: '../../../../../../langchain/src/document_loaders/tests/example_data/example_separator.csv',
    line: 1
  },
  id: undefined
}
```

```typescript theme={null}
console.log(docs[0].metadata)
```

```javascript theme={null}
{
  source: '../../../../../../langchain/src/document_loaders/tests/example_data/example_separator.csv',
  line: 1
}
```

## Usage, extracting a single column

Example CSV file:

```csv theme={null}
id｜html
1｜"<i>Corruption discovered at the core of the Banking Clan!</i>"
2｜"<i>Reunited, Rush Clovis and Senator Amidala</i>"
3｜"<i>discover the full extent of the deception.</i>"
4｜"<i>Anakin Skywalker is sent to the rescue!</i>"
```

```typescript theme={null}
import { CSVLoader } from "@langchain/community/document_loaders/fs/csv";

const singleColumnLoader = new CSVLoader(
  exampleCsvPath,
  {
    column: "html",
    separator:"｜"
  }
);

const singleColumnDocs = await singleColumnLoader.load();
console.log(singleColumnDocs[0]);
```

```javascript theme={null}
Document {
  pageContent: '<i>Corruption discovered at the core of the Banking Clan!</i>',
  metadata: {
    source: '../../../../../../langchain/src/document_loaders/tests/example_data/example_separator.csv',
    line: 1
  },
  id: undefined
}
```

***

## API reference

For detailed documentation of all CSVLoader features and configurations head to the [API reference](https://api.js.langchain.com/classes/langchain_community_document_loaders_fs_csv.CSVLoader.html).

***

<div className="source-links">
  <Callout icon="edit">
    [Edit this page on GitHub](https://github.com/langchain-ai/docs/edit/main/src/oss/javascript/integrations/document_loaders/file_loaders/csv.mdx) or [file an issue](https://github.com/langchain-ai/docs/issues/new/choose).
  </Callout>

  <Callout icon="terminal-2">
    [Connect these docs](/use-these-docs) to Claude, VSCode, and more via MCP for real-time answers.
  </Callout>
</div>
