Skip to main content
`Ctrl`+`K`

# Writing tabular data

With the `write_tabular` app, `cogent3` “TabularTypes” (`Table`, `DictArray`, `DistanceMatrix`) are supported for writing to disk.

Let’s generate a `cogent3` `Table` to use in the examples below. One way to do that is by applying the `tabulate_stats` app to a model result.

## Writing a CSV file

To write in CSV format, we create the `write_tabular` app with `format_name="csv"`.

## Writing a TSV file

To write in TSV format, we create the `write_tabular` app with `format_name="tsv"`.

## Using `write_tabular` in a composed process

Instead of applying the apps sequentially as above, we can add apps into a composed process, and apply the process to a data store. In this example, we define a process that calculates an unaligned distance measure between sequences, writing these estimated distances to a tsv file.

Tip

When running this code on your machine, remember to replace `path_to_dir` with an actual directory path.