cancel
Showing results for 
Search instead for 
Did you mean: 

Remove repeated row in 2D array

Nextal
Member

Remove repeated row in 2D array

Message contains an image

Hi,

 

How can I remove the row for second repeated data in my 2D array regardless of the 2D array size.

 

111.PNG

11 REPLIES 11
altenbach
Knight of NI

Re: Remove repeated row in 2D array

  • In your example, the data is not repeated because the rows differ in the third column. you need to be more specific.
  • Are (pseudo-) duplicate rows always adjacent as in your example?
  • What is the datatype of the array? (string, numeric?)
  • Is the pattern very regular? (i.e. would it be sufficient to simply remove e.g. the rowns with an odd index?)
  • If the answer  to the above question is NO, please show a more typical pattern.
Nextal
Member

Re: Remove repeated row in 2D array

Message contains an image

Hi Altenbach,

 

As long as the first 2 column repeats, I will delete the second repeated row. The datatype is double. The repeated data is different at every run.

1121.png

Trusted Enthusiast

Re: Remove repeated row in 2D array

Use a shift register in a FOR loop to keep track of the n-1 row data.

altenbach
Knight of NI

Re: Remove repeated row in 2D array

Message contains a hyperlink Message contains an image

With a few simple strikes of the mouse, you could probably adapt this example (i.e. change the array of strings to an array of DBL and select key column #0). Let me know if you have problems.

 

 

(Do we really need to look at the second column, FOr you data it seems that looking at the first column might be sufficient.)

Nextal
Member

Re: Remove repeated row in 2D array

Yes, I need to look at the second column this is just a portion of the array.

altenbach
Knight of NI

Re: Remove repeated row in 2D array

Can you attach a simple VI that contains the array of post #3 as a diagram constant?

 

The basic algorithm remians the same, but instead of a single column you would take the array subset of the first two columns, autoindex it the same, and compare the array of two elements with the previous (compare aggregates).

Nextal
Member

Re: Remove repeated row in 2D array

Message contains an image

Is it okay for me to post snippets? This is my first time creating a snippets.

 

array.png

altenbach
Knight of NI

Re: Remove repeated row in 2D array

Message contains an image Message contains an attachment

Try this...

 

 

 

There are many variations possible. Smiley Very Happy

Highlighted
Nextal
Member

Re: Remove repeated row in 2D array

Message contains an image

1111png.png