Get Table from a Text File
Verb: textReadTable
Available from: <Standard>
Gets a data table from a text file using character or size separators.
Syntax
textReadTable [--hasheaders(Boolean)] [--usefunction(Boolean)] [--operator(ConditionalOperators)] --right(String) [--negate(Boolean)] [--stopwheninvalid(Boolean)] [--readfromstart(Boolean)] --delimiter(TextDelimiterOption) --characters(String) --lengths(List<Numeric>) --file(TextFileReader) (DataTable)=value
Inputs
Script | Designer | Required | AcceptedTypes | Description |
---|---|---|---|---|
--hasheaders | Has headers | Optional | Boolean | When enabled, interprets the worksheet's first line as a header. |
--usefunction | Validate lines | Optional | Boolean | When enabled, allow a validation to be added to the table lines. |
--operator | Operator | Optional | ConditionalOperators | Conditional operator that is applied to each table row. The available operators are:
|
--right | Comparison value | Only whenValidate lines is True | Text | Value used in comparison with each value of the table rows. |
--negate | Negate | Optional | Boolean | When enabled, negates the result of the validation. |
--stopwheninvalid | When invalid | Optional | Boolean | This option must be enabled to stop reading when a row is invalid in validation. |
--readfromstart | Read from start | Optional | Boolean | This option must be enabled so that the file reading starts at the beginning instead of the current position. |
--delimiter | Delimiter type | Required | TextDelimiterOption | Option for the type of separator used for reading. The available types are:
|
--characters | Delimiter | Only whenDelimiter type is ByCharacters | Text | Separator (delimiter) used to identify table columns. |
--lengths | Lenghts | Only whenDelimiter type is ByLengths | List<Number>, Text | Length in characters of each cell. |
--file | File reader | Required | Text File Reader | Variable with the text file to open for reading. |
Outputs
Script | Designer | AcceptedTypes | Description |
---|---|---|---|
value | Data table | Data Table | List with data obtained from the table. |
Example
Example 1: Obtains data from a table through the specified size separators "5,3,8", returning such data in a list.
defVar --name textReader --type TextFileReader
defVar --name dataTable --type DataTable
// Open the file informed for reading.
// Download the following file to execute the command.
openTextReader --share "ReadWrite" --path "tableText.txt" --encoding "Default" textReader=value
textReadTable --hasheaders --delimiter "ByLengths" --lengths "5,3,8" --file ${textReader} dataTable=value
logMessage --message "${dataTable}" --type "Info"
Example 2: Get data from a table through the specified character separator "/", returning such data in a list.For the correct operation of the script above, it is necessary to download the file and enter its path in the "Path" parameter of the command "Open Text File for Reading".
defVar --name textReader --type TextFileReader
defVar --name dataTable --type DataTable
// Open the file informed for reading.
// Download the following file to execute the command.
openTextReader --share "ReadWrite" --path "tableText.txt" --encoding "Default" textReader=value
textReadTable --hasheaders --delimiter "ByCharacters" --characters "/" --file ${textReader} dataTable=value
logMessage --message "${dataTable}" --type "Info"
For the correct operation of the script above, it is necessary to download the file and enter its path in the "Path" parameter of the command "Open Text File for Reading".
Remarks
In Lenghts, the cell length must respect the smallest cell size in each column. To use the Get Table from a Text File command, you must have a text file open for reading, obtaining it with the Open Text File for Reading command.