Skip to main content

fileUtils methods

JavaScript API methods for parsing and uploading files.

Use fileUtils JavaScript API methods to parse CSV, JSON, and XLSX files.

warning

These methods are not available within transformers.

Methods for parsing CSV, JSON, and XLSX files.

fileUtils.parseCSV()

Parses a CSV file. Returns a Promise that resolves to a list of objects with one key per column.

valuerequired
string

The Base64-encoded CSV file to parse.

options
object[]

Additional configuration options.

header
boolean

Whether to include the header row. Defaults to true.

Example

Parse the contents of the file uploaded using uploadFileButton. The results array represents each row of the CSV, where results[0] is the first row.

const results = await fileUtils.parseCSV(uploadFileButton.value[0]);

fileUtils.parseJSON()

Parses a JSON file. Returns a Promise that resolves to an object with the file's contents.

valuerequired
string

The Base64-encoded JSON file to parse.

Example

Parse the contents of the file uploaded using uploadFileButton into the results array.

const results = await fileUtils.parseJSON(uploadFileButton.value[0]);

fileUtils.parseXLSX()

Parses an XLSX file. Returns a Promise that resolves to an object with the file's contents.

valuerequired
string

The Base64-encoded XLSX file to parse.

options
object[]

Additional configuration options. See SheetJS for available options.

Example

Parse the contents of the file uploaded using uploadFileButton, including blank rows, into the results array.

const results = await fileUtils.parseXLSX(uploadFileButton.value[0], {"blankrows": true});