Skip to main content
Parse TSV (tab-separated values) strings into the Data structure expected by @graphysdk/core.

fromTSV

import { fromTSV } from '@graphysdk/data-import-utils/tsv';

const data = fromTSV('Name\tRevenue\nAcme\t1000\nGlobex\t2000');

Signature

function fromTSV(input: string, options?: DelimitedParseOptions): Data

Options

hasHeader
boolean
default:"true"
Whether the first row contains column headers. When false, columns are auto-named Column 1, Column 2, etc.
locale
VizLocale
default:"EN_US"
Locale for number parsing. Determines thousand/decimal separator conventions. For example, 'PT_PT' treats 1.000,50 as 1000.5.
maxFileSize
number
default:"5"
Maximum allowed input size in megabytes. Throws an error if the input exceeds this limit.

Examples

Without Headers

const data = fromTSV('Acme\t1000\nGlobex\t2000', { hasHeader: false });
// Columns auto-named: "Column 1", "Column 2"
Files with .tab extension are also treated as TSV.