cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Choose Language Hide Translation Bar
tarkan_bih
Level III

Convert a list of strings into a column names

I am trying a to run a script that uses a regex to find column names and puts them in a list to then stack. I am struggling to get the actual stack part to work and I think it has to do with the list containing strings rather then column names. Is there a way to convert a list strings into column names?

 

ref = open(dir||datafile);

allColNames = ref << getcolumnnames;
edgeCols = {};

Ncols = N items(allColNames);
for(i = 1, i <= Ncols, i++,
	cname = Column(allColNames[i]) << get Name;
	if(!Is Missing (regex(cname,"EDGE\d+") ),
		insert into(edgeCols,cname);
	);
);


edge stack = ref << stack(
	columns(EdgeCols),
	Source Label Column("Label");
	Source Data Column("Data");
	Output Table("Stack");
);
1 ACCEPTED SOLUTION

Accepted Solutions
gzmorgan0
Super User (Alumni)

Re: Convert a list of strings into a column names

Your syntax for stack is incorrect:

  • there are semicolons where there should be commas
  • it is not Source Data Column but Stacked Data Column
edge stack = ref << stack(
	columns( edgeCols),
	Source Label Column("Label"),
	Stacked Data Column("Data"),
	Output Table("Stack")
);

View solution in original post

1 REPLY 1
gzmorgan0
Super User (Alumni)

Re: Convert a list of strings into a column names

Your syntax for stack is incorrect:

  • there are semicolons where there should be commas
  • it is not Source Data Column but Stacked Data Column
edge stack = ref << stack(
	columns( edgeCols),
	Source Label Column("Label"),
	Stacked Data Column("Data"),
	Output Table("Stack")
);