04-22-2017 04:50 PM
Hey all,
I'm fairly new to Labview, and I would like to conditionally delete rows from a table consisting of multiple rows columns (basically a 2D array). I used the "replace array subset" function to 'remove' the unwanted rows, but it seems that I've lost the rest of the columns in the process.
Any hints as how to delete the unwanted rows while keeping all columns intact would be much appreciated.
04-22-2017 04:52 PM
Use DELETE FROM ARRAY.
Blog for (mostly LabVIEW) programmers: Tips And Tricks
04-22-2017 05:16 PM
Hi Steve,
I'm not sure hot to wire the "Delete from array" exactly to get what I want. I want to delete all rows which do not contain "Tomato".
The delete from array function needs the indexes of all the rows which need to be deleted. The only way I can think to get that is to use the "search 1D array" function and get the indexes of all the rows I don't want. But I can only search for one element. But instead I'd like to search for all other elements which do not equal the one I specify.
04-22-2017 06:18 PM
This is based on your initial vi. Please note the image is a snippet
04-22-2017 07:03 PM - edited 04-22-2017 07:04 PM
@Zeustra wrote:
Any hints as how to delete the unwanted rows while keeping all columns intact would be much appreciated.
04-22-2017 11:18 PM
@altenbach wrote:
@Zeustra wrote:
Any hints as how to delete the unwanted rows while keeping all columns intact would be much appreciated.
- The overall patterns of your original code is fine, bot you should not slice out the first column if you want to keep the entire array. Place the entire array into the shift register, wire both indices to index array (one is zero for the first row and one in N for the row number) for comparison. Reshape the number of valid rows at the end.
1. Thank you altenbach. You've been very helpful so far. I didn't know about conditional looping, I learned that from you today :).
2. You're correct, I'm slicing off the first column and that's an issue for you. Could you please elaborate on the part of dealing with this issue? If I understand correctly, you're saying I should place 2 Index Array functions, one indexed at the first row and another at the Nth row? How do I wire them exactly?
I'm not sure where to go from there honestly.
Thank you in advance and sorry I'm quiet a beginner that's trying to self teach.
04-23-2017 12:17 AM
Maybe like this?
There are plenty ways to do this, (I would stick with the simple earlier solution, of course)
02-07-2018 08:18 PM
Excellent bit of code. Thanks for posting the final version!