<!-- Source: https://docs.squirro.com/en/latest/api/squirro.lib.nlp.steps.loaders.FileLoader.html -->
# FileLoader

**`class FileLoader(config)`**

Bases: [`Loader`](squirro.lib.nlp.steps.loaders.Loader.md#squirro.lib.nlp.steps.loaders.Loader)

The file [`Loader`](squirro.lib.nlp.steps.loaders.Loader.md#squirro.lib.nlp.steps.loaders.Loader) looks in a specified directory_field directory for files
and loads these files either line by line or as a whole and transforms them into [`Document`](../technical/libnlp/base.md#squirro.lib.nlp.document.Document) items.

Parameters

- `type` ([`str`](https://docs.python.org/3.11/library/stdtypes.html#str)) – file
- `directory_field` ([`str`](https://docs.python.org/3.11/library/stdtypes.html#str)) – name of field to store directory path of a loaded file
- `encoding` ([`str`](https://docs.python.org/3.11/library/stdtypes.html#str)`, ``'utf-8'`) – given file’s encoding
- `output_field` ([`str`](https://docs.python.org/3.11/library/stdtypes.html#str)) – name of field to store line or whole file
- `per_line` ([`bool`](https://docs.python.org/3.11/library/functions.html#bool)`, ``False`) – indicates if each line represents a different item document

**Example**

```json
{
    "step": "loader",
    "type": "file",
    "directory_field": "loaded_file_path",
    "output_field": "file_content"
}
```

Methods SummaryMethods Documentation

**`process(directory)`**

Process a directory and yield documents.

Parameters

`directory` ([`str`](https://docs.python.org/3.11/library/stdtypes.html#str)) – path to directory with *.txt files

Returns

Generator of Documents read from files

Return type

generator([Document](../technical/libnlp/base.md#squirro.lib.nlp.document.Document))
