tsvImport
Type
command
Summary
Parse tabular data from a text into an array
Syntax
tsvImport <pText>,<pOptions>,<rArray>
Description
This command takes in a string, computes the data based on optional parameters and returns it as an array.
The quoting rule determines how quotes are treated in the data to import.
If it is none
then quotes have no effect on parsing,
and the data is just split based on the chosen delimiter.
Otherwise quoted values can contain the delimiter itself
as well as return characters.
When specifying the quoting-rule for TSV import, consider the following options:
- "all": All fields are quoted
- "minimal": Fields with special characters (like delimiter) have quotes
- "none": Quotes have no effect on parsing
Parameters
Name | Type | Description |
---|---|---|
pText | Text to be parsed for data | |
pOptions | An array of options to use when importing tsv. The keys are as follows:
| |
rArray | Returns a nested array with data parsed from input text with format: { "headers": [ col1header, col2header,...], "data": [ [row1col1data, row1col2data, ...], [row2col1data, row2col2data, ...] ] } |
Examples
local tFile
answer file "Select a tsv file" with type "TSV files|tsv|TSV"
put the result into tFile
local tText
put url ("binfile:" & tFile) into tText
local tArray
tsvImport \
tText, \
{ "has-header-row": true }, \
tArray