# TextLoader

> **Class** in `langchain_community`

📖 [View in docs](https://reference.langchain.com/python/langchain-community/document_loaders/text/TextLoader)

Load text file.

## Signature

```python
TextLoader(
    self,
    file_path: Union[str, Path],
    encoding: Optional[str] = None,
    autodetect_encoding: bool = False,
)
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `file_path` | `Union[str, Path]` | Yes | Path to the file to load. |
| `encoding` | `Optional[str]` | No | File encoding to use. If `None`, the file will be loaded with the default system encoding. (default: `None`) |
| `autodetect_encoding` | `bool` | No | Whether to try to autodetect the file encoding if the specified encoding fails. (default: `False`) |

## Extends

- `BaseLoader`

## Constructors

```python
__init__(
    self,
    file_path: Union[str, Path],
    encoding: Optional[str] = None,
    autodetect_encoding: bool = False,
)
```

| Name | Type |
|------|------|
| `file_path` | `Union[str, Path]` |
| `encoding` | `Optional[str]` |
| `autodetect_encoding` | `bool` |


## Properties

- `file_path`
- `encoding`
- `autodetect_encoding`

## Methods

- [`lazy_load()`](https://reference.langchain.com/python/langchain-community/document_loaders/text/TextLoader/lazy_load)

---

[View source on GitHub](https://github.com/langchain-ai/langchain-community/blob/a6a6079511ac8a5c1293337f88096b8641562e77/libs/community/langchain_community/document_loaders/text.py#L13)