Skip to main content

tsvExportToFile

Type

command

Summary

Converts a data array into a delimiter separated string and saves it into a file

Syntax

tsvExportToFile <pArray>,<pOptions>,<pFile>

Description

This command takes in an array, converts it into a delimiter separated text based on optional parameters and saves the processed string into a file in the current defaultFolder directory.

When specifying the quoting-rule for TSV export, consider the following options:

  • "all": Quotes all fields for consistency.
  • "minimal": Quotes fields with special characters to ensure data integrity.
  • "none": Does not quote any fields, potentially increasing readability but may cause issues with special characters.

Parameters

NameTypeDescription

pArray

Input nested data array with format: { "headers": [ col1header, col2header,...], "data": [ [row1col1data, row1col2data, ...], [row2col1data, row2col2data, ...] ] }

pOptions

An array of options to use when handling tsv. The keys are as follows:

  • "has-header-row": whether to treat the first row of data as column header names. Defaults to false.
  • "delimiter": character used to delimit values. Defaults to tab.
  • "quoting-rule": how tsv values should be quoted in the output file; one of 'all', 'minimal', or 'none'.

pFile

File name with the data saved.

Examples

local tArray
put { \
"headers":["ID","Name"], \
"data": [ \
["1","John"], \
["2","Doe"] \
] \
} \
into tArray

local tOptions
put { "has-header-row": true } into tOptions

local tFile
put "example.tsv" into tFile

tsvExportToFile \
tArray, \
tOptions, \
tFile