Take a delimited string and parse it to separate columns.
See LabTalk Supported Functions for CatIndex, and Catrows.
Dialog box not available from a menu command in the user interface. As with any X-Function dialog, open the Script or Command Window, type the following and press ENTER.
text2cols -d
For script access, see Command Line Usage, next.
text2cols ix:=[Book2]Sheet1!B delimiter:=pipe; // take pipe-separated strings in [Book2]Sheet1!B as input, output values to separate columns in new sheet
Please refer to the page for additional option switches when accessing the x-function from script
Display Name |
Variable Name |
I/O and Type |
Default Value |
Description |
---|---|---|---|---|
Text Column | ix | Input vector<string> |
|
Text Column. Cell(s) contain a string of delimited values. Delimiter must be one of those listed for Delimiter. |
Delimiter | delimiter | Input int |
|
Delimiter, allowed values:
|
Include Other Column(s) | nosplit | Input int |
|
Copy over other columns with the output?
|
Other Column(s) | other | Input range |
|
Other columns to be copied over with output (parsed data). |
Output | rd | Output ReportData |
|
Output. Delimited string is parsed to separate cells (columns). |
This X-Function takes a cell or column of delimited values and parses them to new columns.
This example imports an ASCII file containing categorical data, uses the catrows()$ function to obtain row indices for each category, then outputs those row indices to new columns. The resulting sheet text2cols lists row indices for each category.
// create an empty book and import the file automobile.dat into the new book newbook; string fname$= system.path.program$ + "Samples\Statistics\automobile.dat"; impASC; // set column 2 as categorical and sort it in ascending order wks.col2.categorical.type=2; wks.col2.categorical.sort=1; // get column 2 into range variable rA range rA = [automobile]automobile!"Make"; // create a new book and use category function to copy categories in rA to column A of newbook // to column B, add row indices of occurrence for each category, as a pipe-separated list newbook; col(A)=category(rA)$; col(B)=catrows(rA)$; // taking pipe-separated strings in [Book2]Sheet1!B as input, output values to new sheet in <input>. text2cols ix:=[Book2]Sheet1!B delimiter:=pipe nosplit:=1 other:=[Book2]Sheet1!A;
Keywords:string processing, category, catindex, catrows