> For the complete documentation index, see [llms.txt](https://php-etl.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://php-etl.gitbook.io/docs/extractors/csv.md).

# CSV

Extracts data from a character-separated values file.

```php
$etl->extract('csv', 'path/to/file.csv', $options);
```

## Options

### Columns

Columns that will be extracted. If `null`, all columns will be extracted and the first line will be used as the columns names.

| Type  | Default value |
| ----- | ------------- |
| array | `null`        |

To select which columns will be extracted, use an array with the columns list:

```php
$options = ['columns' => ['id', 'name', 'email']];
```

To rename the columns, use an associative array where the `key` is the name of the column in the file and the `value` is the name that will be used in the etl process:

```php
$options = ['columns' => [
    'id' => 'id',
    'full_name' => 'name',
    'email_address' => 'email',
]];
```

If your file does not contains the columns names, you may set the name and the index of the columns to extract starting at 1:

```php
$options = ['columns' => [
    'id' => 1,
    'name' => 2,
    'email' => 3,
]];
```

### Delimiter

Field delimiter (one character only).

| Type   | Default value |
| ------ | ------------- |
| string | ,             |

```php
$options = ['delimiter' => ';'];
```

### Enclosure

Field enclosure character (one character only).

| Type   | Default value |
| ------ | ------------- |
| string |               |

```php
$options = ['enclosure' => '"'];
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://php-etl.gitbook.io/docs/extractors/csv.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
