BookmarkSubscribe
Choose Language Hide Translation Bar
Highlighted
dghidoni2
Community Trekker

verify if an excel file is empty in JSL

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

0 Kudos
1 ACCEPTED SOLUTION

Accepted Solutions
ms
Super User ms
Super User

Re: verify if an excel file is empty in JSL

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

);

0 Kudos
2 REPLIES 2
ms
Super User ms
Super User

Re: verify if an excel file is empty in JSL

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

);

0 Kudos
dghidoni2
Community Trekker

Re: verify if an excel file is empty in JSL

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

0 Kudos