Hi, I am trying to validate that a data table contains a certain column name prior to creating graphs:
hasname1 = 0; for (colval == 1, colval <= Ncols(dt), colval++, colName = Column Name(colval); if ( colName == "name1", hasname1 = 1;
);if (hasname1 == 1, //create graph );
However, the comparison never returns true because "name1" is a string data type, and the column name returned from Column Name(colval) is some other data type.
How can I get a string value from a Column Name to make a valid string comparison?
Go to Solution
You can use dt << get column names(string); to get column names as a string instead of a column object.
Try this single line of code. Should assign 1 or 0 to hasname1.
hasname1 = Contains( dt << get column names( string ), "name1" );
Works, great, and much shorter than what I was doing. Thank you.