Check column name if existingHi,
I have a list of column names that I need to check from my table if it exist.
How will I check every columns of the table and prompt an error and stop the program from running if it is not existing?
col_list = {"Col1", "Col2", "Col3", "Col4", "Col5" };
//checks column if exist<BR /><BR /> //..code continue running<BR />
//if column doesn't exist<BR />
//..code will stop script & error prompt
Mass CustomizationRe: Check column name if existingHere is a modification of the script that I previously posted.
I strongly suggest that you take the time to read the Scripting Guide found in the JMP Documentation Library, under the Help pull down menu so you will be able to take this sample code and use it to solve your own scripting needs.
animals = Open( "$SAMPLE_DATA\Animals.jmp" );
dt_animals = Data Table( "Animals" );
col_list = {"species", "subject", "miles", "season", "name"};
notFound = {};
For( i = 1, i <= N Items( col_list ), i++,
If( Try( Column( col_list[i] ) << get name, "" ) == "",
Insert Into( notFound, col_list[i] )
)
);
If( N Items( notFound ),
nf = New Window( "Error:",
V List Box(
Text Box( "The following columns are required" ),
Text Box( "but were not found in the data table" ),
List Box( notFound )
)
);
throw();
);Re: Check column name if existingThe prompt where it will tell what column is missingRe: Check column name if existingWhat is it that isn't working? I ran your code, and when it reached the column called "name" the code stopped.
The value of the variable "i" ended up as 5, since it stopped processing on the 5th loop. If it had completed processing, the variable "i" would have been 6.
If there was code beyond this piece of code, it would not have been processed.
Re: Check column name if existinganimals = Open( "C:\Animals.jmp" );
dt_animals = Data Table( "Animals" );
col_list = {"species", "subject", "miles", "season", "name"};
For( i = 1, i <= N Items( col_list ), i++,
If( Try( Column( col_list[i] ) << get name, "" ) == "",
Throw()
)
);
I'm sure I missed something, it's not working for me
Re: Check column name if existingThe method I use is
col_list = {"col1", "col2", "col3"};
for(i=1,i<=N Items(col_list),i++,
if(try(column(col_list[i])<<GET name=""></GET>