import CodeBlock from "@theme/CodeBlock";
import CodeSource from "!raw-loader!../../../../../examples/readers/src/simple-directory-reader";
import CodeSource2 from "!raw-loader!../../../../../examples/readers/src/custom-simple-directory-reader";

# Loader

Before you can start indexing your documents, you need to load them into memory.

All "basic" data loaders can be seen below, mapped to their respective filetypes in `SimpleDirectoryReader`. More loaders are shown in the sidebar on the left.
Additionally the following loaders exist without separate documentation:

- `AssemblyAIReader` transcribes audio using [AssemblyAI](https://www.assemblyai.com/).
  - [AudioTranscriptReader](../../api/classes/AudioTranscriptReader.md): loads entire transcript as a single document.
  - [AudioTranscriptParagraphsReader](../../api/classes/AudioTranscriptParagraphsReader.md): creates a document per paragraph.
  - [AudioTranscriptSentencesReader](../../api/classes/AudioTranscriptSentencesReader.md): creates a document per sentence.
  - [AudioSubtitlesReader](../../api/classes/AudioTranscriptParagraphsReader.md): creates a document containing the subtitles of a transcript.
- [NotionReader](../../api/classes/NotionReader.md) loads [Notion](https://www.notion.so/) pages.
- [SimpleMongoReader](../../api/classes/SimpleMongoReader) loads data from a [MongoDB](https://www.mongodb.com/).

Check the [LlamaIndexTS Github](https://github.com/run-llama/LlamaIndexTS) for the most up to date overview of integrations.

## SimpleDirectoryReader

[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/run-llama/LlamaIndexTS/tree/main/examples/readers?file=src/simple-directory-reader.ts&title=Simple%20Directory%20Reader)

LlamaIndex.TS supports easy loading of files from folders using the `SimpleDirectoryReader` class.

It is a simple reader that reads all files from a directory and its subdirectories.

<CodeBlock language="ts">{CodeSource}</CodeBlock>

Currently, the following readers are mapped to specific file types:

- [TextFileReader](../../api/classes/TextFileReader.md): `.txt`
- [PDFReader](../../api/classes/PDFReader.md): `.pdf`
- [PapaCSVReader](../../api/classes/PapaCSVReader.md): `.csv`
- [MarkdownReader](../../api/classes/MarkdownReader.md): `.md`
- [DocxReader](../../api/classes/DocxReader.md): `.docx`
- [HTMLReader](../../api/classes/HTMLReader.md): `.htm`, `.html`
- [ImageReader](../../api/classes/ImageReader.md): `.jpg`, `.jpeg`, `.png`, `.gif`

You can modify the reader three different ways:

- `overrideReader` overrides the reader for all file types, including unsupported ones.
- `fileExtToReader` maps a reader to a specific file type. Can override reader for existing file types or add support for new file types.
- `defaultReader` sets a fallback reader for files with unsupported extensions. By default it is `TextFileReader`.

SimpleDirectoryReader supports up to 9 concurrent requests. Use the `numWorkers` option to set the number of concurrent requests. By default it runs in sequential mode, i.e. set to 1.

### Example

<CodeBlock language="ts" showLineNumbers metastring="{8-12,17-21}">
  {CodeSource2}
</CodeBlock>

## API Reference

- [SimpleDirectoryReader](../../api/classes/SimpleDirectoryReader.md)
