> For the complete documentation index, see [llms.txt](https://docs.octoxlabs.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.octoxlabs.com/adapters/c/csv-file.md).

# CSV File

The CSV File adapter reads devices from a CSV file on the connector host. OctoXLabs uses it to add devices that no other adapter covers.

## Use cases

* List devices imported from CSV.

```
Adapters = csv-file
```

* Find imported devices that are missing from Active Directory.

```
Adapters = csv-file AND NOT Adapters = active-directory
```

## Before you begin

### Network

| Source         | Destination                                                            | Port | Protocol |
| -------------- | ---------------------------------------------------------------------- | ---- | -------- |
| Not applicable | The file is read from the connector host. No network access is needed. | -    | -        |

### Required permissions

| Scope or role           | Permission | Needed for                                                                       |
| ----------------------- | ---------- | -------------------------------------------------------------------------------- |
| Read access to the file | Read       | The connector process must read the file in `/opt/octoxlabs/connector/media/csv` |

## Create credentials in CSV File

This adapter has no credentials. Prepare the file instead.

{% stepper %}
{% step %}

### Create the CSV file

Create a CSV file with a header row. Name the columns with the canonical column names listed in **Fields fetched** so that rows map automatically. Separate multiple values in one cell with the list separator (default `|`).
{% endstep %}

{% step %}

### Copy the file to the connector

Copy the file to `/opt/octoxlabs/connector/media/csv` on the connector host. The connector must be able to read it, so check the file permissions.
{% endstep %}

{% step %}

### Name the file

Enter the file name in the **Filename** parameter. A glob pattern such as `export_*.csv` is allowed. When several files match, the most recently modified file is used.
{% endstep %}
{% endstepper %}

## Connection parameters

| Parameter       | Required | Type               | Default  | Description                                                                                                                   |
| --------------- | -------- | ------------------ | -------- | ----------------------------------------------------------------------------------------------------------------------------- |
| Filename        | Yes      | Text               |          | Name or glob pattern of the CSV file, relative to `/opt/octoxlabs/connector/media/csv`. Absolute paths and `..` are rejected. |
| Hostname Field  | No       | Text               | Hostname | Name of the column with the hostname. Rows without it are skipped.                                                            |
| Last Seen Field | No       | Text               | LastSeen | Name of the column with the last seen date.                                                                                   |
| Group By Field  | No       | Text               |          | Column used to group rows that describe the same host. Leave empty if the file is not grouped.                                |
| Separator       | No       | Text (1 character) | ,        | Column separator.                                                                                                             |
| List Separator  | No       | Text (1 character) | \|       | Separator for several values in one cell.                                                                                     |
| Quote Char      | No       | Text (1 character) | "        | Quote character for cell values.                                                                                              |

## Troubleshooting

| Error message                                                                 | Cause                                              | Fix                                                        |
| ----------------------------------------------------------------------------- | -------------------------------------------------- | ---------------------------------------------------------- |
| File not found with this pattern.                                             | No file in the CSV folder matches Filename.        | Copy the file to the folder and check the name or pattern. |
| No such file.                                                                 | The resolved path is not a file.                   | Check Filename.                                            |
| (file name) file is empty.                                                    | The file has no header row.                        | Add a header row.                                          |
| An absolute path is not allowed; give a name relative to the adapter's folder | Filename starts with `/`.                          | Use a relative name.                                       |
| '..' is not allowed; the file must stay inside the adapter's folder           | Filename contains `..`.                            | Use a name inside the CSV folder.                          |
| Header ... has bad char. Please check your headers                            | A header contains characters that are not allowed. | Rename the column.                                         |

## Change history

{% hint style="info" %}
Available starting from version 2.5.1.
{% endhint %}
