> ## Documentation Index
> Fetch the complete documentation index at: https://docs.e6data.com/llms.txt
> Use this file to discover all available pages before exploring further.

# CSV

> Read CSV headers and typed columns, then publish and verify a CSV dataset.

How-to guide

The CSV connector reads comma-separated files and writes CSV datasets. It supports append and whole-dataset overwrite. It does not support row updates, deletes, or merges.

## Before you start

Prepare file access and a client connection using [Read and write files](https://docs.e6data.com/transformation/connectors/files.md). For the read example, place this UTF-8 file in accessible storage:

```csv theme={"theme":{"light":"github-light","dark":"github-dark"}}
order_id,amount
1,12.5
2,7.5
```

## Read data

Use an explicit schema to keep the identifier and amount types fixed. The header must match the column names and order.

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
CREATE OR REPLACE TEMP VIEW csv_orders (
  order_id BIGINT,
  amount DOUBLE
)
USING csv
OPTIONS (
  path '<input-csv-file-or-folder>',
  header 'true',
  pathGlobFilter '*.csv'
);

SELECT order_id, amount FROM csv_orders ORDER BY order_id;
```

Expect `(1, 12.5)` and `(2, 7.5)`. Without an explicit schema, set `inferSchema 'true'` to infer types from a bounded sample. With inference disabled, discovered columns use string types.

## Write data

Use the `spark` connection from the shared file guide. Choose a private output directory covered by a writable mount.

```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
output_path = "<mounted-csv-output-directory>"
orders = spark.createDataFrame(
    [(1, 12.5), (2, 7.5)], "order_id BIGINT, amount DOUBLE"
)

orders.write.format("csv").mode("overwrite").option("header", "true").save(output_path)

written = (
    spark.read.format("csv")
    .schema("order_id BIGINT, amount DOUBLE")
    .option("header", "true")
    .load(output_path)
)
written.orderBy("order_id").show()
assert written.count() == 2
```

Use `mode("append")` to add rows. Repeating an append adds another copy of those rows.

## Options

| Option | Default | Read or write | Meaning |
| - | - | - | - |
| `header` | `false` | Both | Read column names from the first record, or write a header in each part file. |
| `delimiter` or `sep` | Comma | Both | Use one single-byte field separator. |
| `quote` | Double quote | Both | Use one single-byte quote character. |
| `escape` | Backslash | Read; fixed for writes | Choose the escape character for reads. Writers keep the default setting and double embedded quotes. |
| `nullValue` | Unset | Both | Choose the text used for a null field. |
| `inferSchema` | `false` | Read | Infer types when no explicit schema is supplied. |
| `compression` | `none` | Both | Reads accept `none` or `zstd`. Writes accept uncompressed output only. |
| `mode` | `FAILFAST` | Read | Invalid input fails the read. Other parsing modes are rejected. |
| `encoding` | UTF-8 | Both | Only UTF-8 is accepted. |

For storage and folder selection options, see [shared read options](https://docs.e6data.com/transformation/connectors/files.md#read-options-shared-by-file-formats). Writer `mode("overwrite")` is separate from the parsing option named `mode`.

## Data types and limits

CSV stores text, so use a schema for numeric, date, or timestamp columns that need stable types. Values must parse as those types. All selected files must have a compatible schema and matching headers.

Quoted fields can contain newlines. The CSV reader handles them directly; a `multiLine` option is not accepted for CSV. Use `compression 'zstd'` for Zstandard input and a matching file filter for compressed names.

Direct writes do not accept partitioning or table-style row mutations. For those operations, choose a supported [table connector](https://docs.e6data.com/transformation/connectors.md).

## Related guides

* [Read and write files](https://docs.e6data.com/transformation/connectors/files.md)
* [Read a CSV header](https://docs.e6data.com/transformation/recipes/files/csv-header.md)
* [Select matching files](https://docs.e6data.com/transformation/recipes/files/folder-filter.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.