Skip to main content

CSV module · writer API

CSVWriter

Write loaders.gl tables back to CSV or another delimiter-separated text representation, including Arrow-backed tables produced by CSVLoader.

What it accepts

Export the same table in a format people can open anywhere.

CSVWriter accepts loaders.gl table data and turns it into interoperable text. Use it at the application boundary when a table needs to leave the binary pipeline.

Input

Rows, columns, or Arrow-backed tables

Output

CSV or delimiter-separated text

Names

Optional display names from metadata

API

Async encode or synchronous text output

Detailed guide

CSVWriter reference

The sections below document imports, encoding forms, and writer options.

CSVWriter writes tabular data into comma-separated value and delimiter-separated value encoding.

Usage​

import {encode} from '@loaders.gl/core';
import type {Table} from 'apache-arrow';
import {CSVWriter} from '@loaders.gl/tables/csv';

declare const table: Table;

const data = await encode(table, CSVWriter); // ArrayBuffer
const text = CSVWriter.encodeTextSync(table, {csv: options}); // string

CSVWriter accepts the Apache Arrow table returned by CSVLoader and loaders.gl row or columnar tables.

CSVWriter Options​

OptionTypeDefaultDescription
csv.useDisplayNamesbooleanfalseIf true, use field metadata.displayName values as column names when available.