> ## Documentation Index
> Fetch the complete documentation index at: https://docs.graphy.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Text

Parse a text string (CSV or TSV) into the [Data structure](/sdk/core/data-structure) expected by `@graphysdk/core`.

## fromText

```typescript theme={null}
import { fromText } from '@graphysdk/data-import-utils/text';

const data = fromText(csvContent, 'csv');
const data = fromText(tsvContent, 'tsv', { hasHeader: false });
```

### Signature

```typescript theme={null}
function fromText(
  input: string,
  format: 'csv' | 'tsv',
  options?: DelimitedParseOptions
): Data
```

## Options

<ParamField path="format" type="TextFileFormat" required>
  The text format: `'csv'` or `'tsv'`.
</ParamField>

<ParamField path="options.hasHeader" type="boolean" default="true">
  Whether the first row contains column headers. When `false`,
  columns are auto-named `Column 1`, `Column 2`, etc.
</ParamField>

<ParamField path="options.locale" type="VizLocale" default="EN_US">
  Locale for number parsing. Determines thousand/decimal separator conventions.
</ParamField>

<ParamField path="options.maxFileSize" type="number" default="5">
  Maximum allowed input size in megabytes.
</ParamField>

## Examples

### Parse CSV from memory

```typescript theme={null}
import { fromText } from '@graphysdk/data-import-utils/text';

const csv = 'Name,Revenue\nAcme,1000\nGlobex,2000';
const data = fromText(csv, 'csv');
```

### Handle a browser text file upload

```typescript theme={null}
import { fromText } from '@graphysdk/data-import-utils/text';

const file: File = input.files[0];
const text = await file.text();
const data = fromText(text, 'csv');
```
