---
title: Export Data to a CSV
---

> [!WARNING]
> Legacy documentation: This documentation applies to **Legacy Deephaven Enterprise only** and does not apply to Core+.

Deephaven supports saving data to a CSV file. To export the results of a query to a CSV, use the `writeCsv` method. The sole argument to the `writeCsv` method is the path to which the file should be written. However, you do need to import the `TableTools` class, as demonstrated below.

```python
from deephaven import *

ttools.writeCsv(tableToExport, "/mnt/exportPath/myResults.csv")
```

```groovy
import com.illumon.iris.db.tables.utils.TableTools

writeCsv(tableToExport, "/mnt/exportPath/myResults.csv")
```

By default null values in the table will be exported as `(null)`. Users can opt to insert blanks instead by adding an additional parameter:

```groovy syntax
writeCsv(sourcePath, destPath, nullsAsEmpty, columns)

writeCsv(tableToExport, "/mnt/exportPath/myResults.csv", true)
```

You can also specify any character that is not a new line character to be used as the delimiter:

```groovy syntax
writeCsv(sourceTable, destPath, compressed, timeZone, nullsAsEmpty, separator, columns)
```

For example, the following queries configures the CSV to use a `|` as the delimiter:

```groovy syntax
import com.illumon.iris.db.tables.utils.DBTimeZone

writeCsv(tableToExport, "/mnt/exportPath/myResults.csv", false, DBTimeZone.TZ_DEFAULT, false, '|')
```

> [!NOTE]
> See also:
> TableTools [JavaDocs](https://docs.deephaven.io/javadoc/20240517/com/illumon/iris/db/tables/utils/TableTools.html#writeCsv-com.illumon.iris.db.tables.Table-boolean-java.lang.String-java.lang.String...-) or [PyDocs](https://docs.deephaven.io/pydocs/code/deephaven.TableTools.html) for more information on `writeCsv`.

> [!CAUTION]
> Important: The path is evaluated on the Deephaven query server. If you do not have access to the query server, you may create a CSV from the Deephaven console instead. This is accomplished by right-clicking on the header row of a table, and then selecting **Export to CSV** from the drop-down menu.
