Chevron Down
Table of Contents
Chevron DownAPI Reference

CSVLoader

Streaming loader for comma-separated value and delimiter-separated value encoded files.

LoaderCharacteristic
File Extension.csv, .dsv
File TypeText
File FormatRFC4180
Data FormatClassic Table
Decoder TypeSynchronous, Asynchronous
Worker Thread SupportNo
Streaming SupportYes

Usage

import {CSVLoader} from '@loaders.gl/obj';
import {load} from '@loaders.gl/core';

const data = await load(url, CSVLoader, options);

Options

The following options are passed on to papaparse:

OptionTypeDefaultDescription
delimiterStringauto-detectThe delimiting character.
headerBooleanauto-detectIf true, the first row of parsed data will be interpreted as field names. If false, the first row is interpreted as data.
newlineStringauto-detectThe newline sequence. Must be \r, \n, or \r\n.
quoteCharString"The character used to quote fields.
escapeCharString"The character used to escape the quote character within a field.
dynamicTypingBooleantrueIf true, numeric and boolean data values will be converted to their type (instead if strings).
commentsStringfalseComment indicator (for example, "#" or "//"). Lines starting with this string are skipped.
skipEmptyLinesStringfalseIf true, lines that are completely empty (those which evaluate to an empty string) will be skipped. If set to 'greedy', lines that don't have any content (those which have only whitespace after parsing) will also be skipped.
transformFunction-A function to apply on each value. The function receives the value as its first argument and the column number or header name when enabled as its second argument. The return value of the function will replace the value it received. The transform function is applied before dynamicTyping.
delimitersToGuessArray[',', '\t', '|', ';']An array of delimiters to guess from if the delimiter option is not set.
fastModeBooleanauto-detectForce set "fast mode". Fast mode speeds up parsing significantly for large inputs but only works when the input has no quoted fields. Fast mode will be auto enabled if no " characters appear in the input.