Hi,
I need to check if required columns are available in a data table. Subsequently, I need to create a pop-up message saying which columns were missing (if any).
I know how to check for one column at a time, but I´m trying to do this in one go e.g. in a loop.
I was attempting something like the below where a "MissingColumns" list is populated with the columns that are not available. This is not working though. What am I doing wrong?
RequiredColumns = {"DateTime", "Animal", "VO2_M", "RQ_M", "FoodInA_M", "WaterInA_M"};
ExistingColumns = SableData << Get column names( String );
MissingColumns = {};
For( i = 1, i <= N Items( RequiredColumns ), i++,
if(!contains(ExistingColumns[i],
Insert Into(MissingColumns,i)))
);<BR /><BR />If( N Items( MissingColumns ) > 0,
New Window( "Missing columns identified", modal,
H List Box(
Spacer Box( size( 5, 0 ) ),
Text Box( MissingColumns )
))
);
Br Julie
I have fixed minor bug in your script:
RequiredColumns = {"DateTime", "Animal", "VO2_M", "RQ_M", "FoodInA_M", "WaterInA_M"};
ExistingColumns = SableData << Get column names( String );
MissingColumns = {};
For( i = 1, i <= N Items( RequiredColumns), i++,
if(!contains(ExistingColumns , RequiredColumns[i]),
Insert Into(MissingColumns, RequiredColumns[i])
);