Parse CSV text into a DataFrame with automatic
dtype inference, and serialize any DataFrame back
to CSV with full formatting control. Mirrors
pandas.read_csv() and
pandas.DataFrame.to_csv().
Edit any code block below and press ▶ Run
(or Ctrl+Enter) to execute it live in your browser.
The simplest call is readCsv(text). The first row is the header,
subsequent rows are data. Column dtypes are inferred automatically.
Empty fields, NA, NaN, null, None,
and several other sentinel strings are automatically converted to null.
Pass extra strings via naValues.
Fields containing the separator, quotes, or newlines can be wrapped in double-quotes.
Use sep to change the delimiter (tab, semicolon, pipe, etc.).
Set indexCol to a column name or position to use that column
as the row index instead of the default RangeIndex.
Use nRows to read only the first N data rows, and
skipRows to skip rows at the start.
toCsv(df) converts a DataFrame back to a CSV string.
Control index inclusion, header, separator, and NA representation.
A DataFrame serialized with toCsv can be
reconstructed with readCsv without data loss.
Parse CSV text into a DataFrame or serialize a DataFrame back to CSV. All options are optional — sensible defaults are provided.
// Parse CSV text → DataFrame
readCsv(text: string, opts?: {
sep?: string, // default ","
naValues?: readonly string[], // extra NA sentinel strings
indexCol?: string | number, // column to use as row index
nRows?: number, // max data rows to read
skipRows?: number, // rows to skip at start
}): DataFrame
// Serialize DataFrame → CSV text
toCsv(df: DataFrame, opts?: {
sep?: string, // default ","
index?: boolean, // default true — include index
header?: boolean, // default true — include header row
naRep?: string, // default "" — NA representation
}): string