11-16-2022 06:00 AM
Say I have the following 2D arrays:
A 1
B 2
C 3
D 4
E 5
A 11
C 22
D 32
F 42
G 53
A 12
D 23
E 55
F 44
H 56
I want to add on to create the final array where the * are empty spaces:
A 1 11 12
B 2 ** **
C 3 22 **
D 4 32 23
E 5 ** 55
F * 42 44
G * 53 **
H * ** 56
How would one proceed? First I was thinking of creating a 1D array of the first column, called say 1stcol, appending them but also removing duplicates.
Then I'd create a while loop, indexing each element of 1st col, where if element of 1stcol = element of 2D array 1 1st col, append element to the first row, and if not found then put empty string.
I don't know if that makes sense but please let me know of any ideas.
11-16-2022 07:06 AM
Hi Jody,
Depending upon how you are getting this data, solution may change but below is what I could think of based on what you have written. You can change the data type from string to numbers or vise versa, if needed.
Also, Map VIs can be used to better organize your data if the application requires.
Hope this gives you some ideas to start with.
11-16-2022 11:37 AM - edited 11-16-2022 11:44 AM
You cannot have empty spaces in numerics, so I assume that all output data should be strings, i.e. a simple 2D array of strings.
Our help is typically faster of you would create and attach a small VI that has a typical inputs as diagram constants so we don't need to tediously create something from scratch. Our time is valuable!
Also be careful to avoid any special cases, for example can you guarantee that all input array have exactly the same number of rows or can the sizes vary? Do we know all possible letters (first column) from the beginning?
11-16-2022 12:02 PM
Assuming all input array have the same size, I made it a 3D array, one plane per input. If the number of rows can differ, we can make it a 1D array of clusters where each cluster contains a 2D array with N rows and two columns, so modify as needed).