LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

detect empty elements when using spreadsheet string to array

Solved!
Go to solution

All, I am converting a large spreadsheet string to array, and the Spreadsheet String To Array vi works great for this. However I would like to detect if there is an error in the data coming in. ultimately I have a 4 column by N row dataset and I would like to identify if on one of the rows I get something less than 4 values. I was hoping if I set the Default Value of the element of the Array Type definition going into the VI with some value I expect to never get that the empty values would be filled with that default and I could check that the output had none of these values. But alas they get 0 instead and 0 is a perfectly valid value I would expect (as is NaN but that's another story). Knowing it probably wouldn't make a difference I also tried changing the default element value for the output indicator as well.

 

Is there any (efficient) way to detect if the values are empty in the input string? Maybe something with the format string? I am attaching a sample of what I tried that didn't work but maybe clarifies my desire. You will see that about 2/3 the way down in the input there are 2 values missing on the input string.

Thanks

0 Kudos
Message 1 of 3
(131 Views)
Solution
Accepted by topic author tshurtz

The best solution is to figure out why you are getting empty data and fix that at the source.

 

The next solution is don't convert the string straight to numeric array.  Convert it to a string array first.  Then search that for empty string elements.

 

Make whatever modifications to the data that you need to.  Then convert the string array to a numeric array.

 

0 Kudos
Message 2 of 3
(122 Views)

Thanks, 

Unfortunately the source is "users" and I have done what I can to prevent errors there but there is only so much I have control over. So my approach is more catch the error and alert the user rather than not know there is a problem and do something unexpected.

This seems to work well and assuming I don't have too big of an array isn't a huge memory hit.

0 Kudos
Message 3 of 3
(85 Views)