Subscribe Bookmark RSS Feed

verify if an excel file is empty in JSL

dghidoni2

Community Trekker

Joined:

May 31, 2013

hello

I have an issue: the data I'm feeding to a JSL script comes from an application which sometimes, when has no data to give, returns an empty excel file.

Is there any way to identify this empty table?

If i try to open it, jmp throws out an error and stops the script.

the funcion "is empty" works on open data table and applying it directly on the file give always the same result, regardless if the file is empty or not.

any suggestion?

thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Solution

To avoid stopping of the script you can enclose the open() within a try() statement. To identify an empty Excel table you can try something like this:

If( Is Missing( Try( dt = Open( "/path/file.xls" ) ) ),

  Show( "NOOO!, Excel table is empty" ); //...jsl code if empty

,

  Show( "Carry on!" ); //...jsl code if file contains data

);

2 REPLIES
Solution

To avoid stopping of the script you can enclose the open() within a try() statement. To identify an empty Excel table you can try something like this:

If( Is Missing( Try( dt = Open( "/path/file.xls" ) ) ),

  Show( "NOOO!, Excel table is empty" ); //...jsl code if empty

,

  Show( "Carry on!" ); //...jsl code if file contains data

);

dghidoni2

Community Trekker

Joined:

May 31, 2013

thank you! I was looking exactly for something like this, able to handle an error without stopping the execution.

I stumbled upon the try function some time ago, but was unable to find it ..

I will use a simpler form inside a cicle upon a list of files

file = "00_DD_.xls";

flag=0;

Try( dt = Open( file ),flag=1 );

and then use the flag to trigger the creation/modification of a list of "bad files", but substantially relying on the try function