LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Removing some zeroes from 2D array

Hello,
 
I'm using read spreadsheet method to import data from a text-file to an array in labview. My problem is that I also need to remove all the zeroes in the array except for the 0's that is next to an element that is NOT 0.
 
I read through many questions regarding removing zeros but havn't been able to find something that I could use.
 
I attached my very simple import VI and the datafile I'm working with.
 
 
Best regards and thanks in advance
 
Simon, Denmark
Download All
0 Kudos
Message 1 of 6
(3,312 Views)
Hi!

You can do a simple parser, which checks if the element before the 0 or after is >0 with case-structure.
Fastest way is to make it find the items which are >0 and scrap up from there.
0 Kudos
Message 2 of 6
(3,304 Views)
thank you for your reply
 
how do I make such a parser? I havn't been able to find a method to compare the current element of the array with the previous or next.
 
thanks
 
Simon
 
 
0 Kudos
Message 3 of 6
(3,301 Views)
And your very simple Import VI doesnt work on your text, hence the spaces after commas, which makes CSV-parseing very hard and the normal Spreadsheet file reader cant read it with Double-format.

It is doable with the spaces, if you ready the items as strings and remove whites.

Best case would be that you remove the useless spaces between numbers and commas, before you even try to read it from the creator of this type of file.

Message Edited by Nallez on 03-05-2007 07:22 AM

0 Kudos
Message 4 of 6
(3,283 Views)
Your array is 2D, so you cannot simply "remove" certain isolated elements.
 
In a 2D array, you can only remove entire rows or columns. Are you trying to get the 2D array subset that contains the nonzero portions including a border of zeroes?
 
 
0 Kudos
Message 5 of 6
(3,267 Views)
Don't mess with the file format as suggested elsewhere. The file is perfectly fine. Simply read it as a string and convert it to an I32 array using "spreadsheet string to array" with ";" as delimiter.
 
Assuming that the data is one nice "island", you could do something simple as in the attached example (LV8.0) to get the 2D subset. Let me know if you don't understand. There are many other ways to do this. 🙂
0 Kudos
Message 6 of 6
(3,260 Views)