2.2.30 text2cols


Menu Information

Column: Text to Columns...

Brief Information

Split a single column of text into multiple columns.

See LabTalk Supported Functions for CatIndex, and Catrows.

Command Line Usage

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

X-Function Execution Options

Please refer to the page for additional option switches when accessing the x-function from script

Variables

Display
Name
Variable
Name
I/O
and
Type
Default
Value
Description
Text Column ix Input
vector<string>
<active>
Text Column. Cell(s) contain a string of delimited texts. Delimiter must be one of those listed for Delimiter.
Delimiter delimiter Input
int
0
Delimiter, allowed values:
  • 0=comma:Comma
  • 1=semicolon:Semicolon
  • 2=pipe:Pipe
  • 3=space:White Space
Include Other Column(s) nosplit Input
int
0
Copy over other columns with the output?
  • 0 = false
  • 1 = true
Other Column(s) other Input
range
<optional>
Available when Include Other Column(s) is checked. Other columns to be copied over with output (parsed data).
Output rd Output
ReportData
[input]<new>
Output. Delimited string is parsed to separate cells (columns).

Description

This X-Function takes a cell or column of delimited text and parses it to new columns.

Examples

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;

Related X-Functions

wxcat