---
title: File Reading Processor
slug: litmusedge/file-reading-processor
docTags: 
createdAt: 2024-10-21T17:54:09.977Z
---

The FileReader processor reads the contents of a file and returns them as a string in the output payload's `value` field.

## Why use the FileReader processor

Use this processor when your flow needs to bring in file-based data, such as a CSV export or a text file written by another system, rather than data that already arrives as a message payload.

## How it works

### Choosing the file

If **File Name** is empty, the processor gets the filename from the `filename` field of the incoming payload. Otherwise, it uses the value entered in **File Name**.

If **Generate Filename From Expression** is enabled, the processor evaluates **File Name** as an expression instead of using it literally. For example, to build a filename from a connection named `AAA`'s `path` and `name` fields, the expression would be `AAA_path + AAA_name + ".txt"`. Static text within an expression must be in quotes.

### Controlling rereads

Normally, an incoming message triggers a file read only if the file has changed since it was last read. **Time Interval in Seconds** overrides this: it forces the file to be treated as unmodified again after the set interval, so the next incoming message re-reads it even if the file's contents haven't changed. Changing any of the processor's settings also resets this unmodified status. Enter `0` to never force a re-read; the file is then read only when it actually changes.

:::hint{type="warning"}
**Caution:** Setting **File Size Limit in Mb** to `0` removes the size limit entirely, letting files of any size be read. This can lead to excessive CPU, memory, and storage use.
:::

### Reading CSV files

When **Input File Type** is set to **CSV**, these parameters apply:

- **CSV Comma** sets the delimiter character. Only the first character you enter is used.
- **CSV Columns Mode** determines how column names are assigned:
  - **Indexed** assumes the file has no header row and names fields `FieldXXX`.
  - **From header** takes field names from the CSV file's header row.
  - **Custom** takes field names from the **CSV Customs Columns** field.

When **Input File Type** is set to **value only**, the processor writes the file's contents directly to the `value` field instead of parsing columns.

### Output format

**Data Output Mode** controls whether the processor sends the file's data as a single message or as one message per record. Per-record output isn't supported for binary or JSON files.

## Parameters

| **Parameter**                     | **Details**                                                                                                                                                                   |
| --------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| File Name                         | The name of the file to read.                                                                                                                                                 |
| Generate Filename From Expression | When enabled, evaluates **File Name** as an expression instead of using it literally.                                                                                         |
| Input File Type                   | The format of the file, for example, JSON, CSV, or Parquet. Determines how the processor parses the file's content.                                                           |
| File Size Limit in Mb             | The maximum file size, in megabytes, that the processor reads. Files that exceed this limit are skipped.                                                                      |
| Time Interval in Seconds          | Forces the file to be treated as unmodified again after this interval, so it's reread on the next incoming message even without a change. Enter `0` to never force a re-read. |
| Data Output Mode                  | Whether the file's data is sent as a single message or one message per record.                                                                                                |
| CSV Comma                         | The delimiter character for CSV files. Only the first character entered is used.                                                                                              |
| CSV Columns Mode                  | How column names are assigned when reading a CSV file: indexed, from header, or custom.                                                                                       |
| CSV Customs Columns               | The custom column names to use when **CSV Columns Mode** is set to custom.                                                                                                    |

