fileUtils

JavaScript API methods for parsing and uploading files.

Methods

Use these methods to parse CSV, JSON, and XLSX files. Note that these methods are not available within transformers.

fileUtils.parseCSV()

Parses a CSV file that resolves to the file's contents.

Syntax

fileUtils.parseCSV(value, options)
value
required

A string to specify the Base64-encoded CSV file.

options
optional

An object that controls settings for the file parsing.

ParameterTypeDescription
headerboolean (optional)Whether the CSV file contains a header. Defaults to true.

Return value

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

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 that resolves to the file's contents.

Syntax

fileUtils.parseJSON(value)
value
required

A string to specify the Base64-encoded JSON file.

Return value

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

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 that resolves to the file's contents.

Syntax

fileUtils.parseXLSX(value)
value
required

A string to specify the Base64-encoded XLSX file.

Return value

Returns a Promise that resolves to an object with the file's contents. The result contains an object for each sheet with a nested object for each row.

Example

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

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