LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I delete records from a 3D array based on values of one field?

Solved!
Go to solution

In the attached  3D array I want to delete all records that do not have 3A900000/3A900001/ or 3A900002 in field 2. Is there an easy way to do this?

 

Thank you.

0 Kudos
Message 1 of 8
(2,967 Views)

chuck72352 wrote:

In the attached  3D array I want to delete all records that do not have 3A900000/3A900001/ or 3A900002 in field 2. Is there an easy way to do this?

 

Thank you.


 

Easy is relative Smiley Wink, but I think people will be able to answer this better if you give some more detail. However, no matter what detail we may get, people will tell you Don't use delete from array in a loop! You will want to search the forums for how to avoid this. Lots of examples. Second, what is "field" two. Is it a row, a column, or a "page"? Remember, in certain situations your array will be padded to hold dimensions properly. You can't just have a 2d array with some rows length 5 and some rows length 4.
0 Kudos
Message 2 of 8
(2,959 Views)

You can't delete rows from any page in a 3D array because that would upset the number of rows, which must remain the same for all pages.  Wire the array into a For Loop with indexing enabled.  This will give you each page.  Use another inner loop to get each row.  Look for the desired number in column 2.  If found, then overwrite the entire row with blank strings.  This will preserve the number of rows for each page of the 3D array.

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 3 of 8
(2,954 Views)
A field is a column.
0 Kudos
Message 4 of 8
(2,946 Views)
Once rows other than 3A900002/ 3A900001/ 3A900000 in column two are deleted there will always be four rows on each page. Note by looking at the data in my attachment each page has 1 row with 3A900001 in column 2, 1 row with 3A900002 in column 2, and 2 rows with 3A900000 in column 2. All other rows on every page I would like to delete.
0 Kudos
Message 5 of 8
(2,944 Views)

Here's my attempt to delete all records on each page that don't have 3A900002 or 3A900001 or 3A900000 in the 2nd column. How can I make it delete an entire record (row) instead of just the value in the fifth column.

 

Thank you.

0 Kudos
Message 6 of 8
(2,927 Views)

OpenG have some useful VIs for array operations such as the following which might be useful to you:

 

Filter 1D Array.png 

 

 

You can download at:

 

http://forums.jkisoft.com/index.php?showtopic=233

Message 7 of 8
(2,920 Views)
Solution
Accepted by topic author chuck72352
Instead of deleting why don't you find and replace instead - much more efficient anyway due to no resizing of the array.  Factor this into your subsequent processing of the array.
Message Edited by battler. on 04-03-2010 08:10 PM
Message 8 of 8
(2,918 Views)