# Read CSV File

The **Read CSV file** block takes any CSV-compatible file as a source and reads it line by line. Has an Each row stream output connector that directs the flow of commands after each row is read. Use the "Row Columns" output variable to get an array of columns for further processing.

The **Read CSV file** is similar in functionality to the **For each loop** block: they both iterate over the array elements, but the **Read CSV file** reads lines. When all lines have been read, the command stream will be sent to the Completed stream connector.&#x20;

The blocks for processing Excel files operate on a similar principle: [**Read XLSX file** ](https://appmaster.gitbook.io/docs/business-logic/block/functions/file/read-xlsx-file)and [**Read XLS file**](https://appmaster.gitbook.io/docs/business-logic/block/functions/file/read-xlsx-file).

{% embed url="<https://youtu.be/Bc9QiMdzPDY>" %}

**Tip:** combine this block with a For Each block to iterate over each column in a row, and then use a Switch block to process columns values based on the column number or column name (see video above for more).

### Flow Connections

* \[Input] In - starts the block's execution.
* \[Output] Each row - activates once for each row in the file.
* \[Output] Completed - activates when all the rows in the file have been iterated over.

### Data Connections

* \[Input] CSV file (file) - CSV file to be read.
* \[Output] Row number (integer) - number of the row currently being read (starting at 1), increases by 1 with every iteration.
* \[Output] Row columns (string array) - contents of the columns of the row currently being read in string format.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://appmaster.gitbook.io/docs/business-logic/block/functions/file/read-csv-file.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
