LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Comparing and eliminating elements in an array to create different worksheets in excel

Hi,

i want to create excel sheets by referencing different dates (from an array) but as some dates are repeated, there will be an error whereby the sheet can't be created. This means that there should be some kind of comparison and elimination to be done but i can't seem to figure it out. Attached are photos for reference. Would appreciate some advice, thank you!

Download All
0 Kudos
Message 1 of 7
(1,164 Views)

Hi jvvvv,

 


@jvvvv wrote:

This means that there should be some kind of comparison and elimination to be done but i can't seem to figure it out.


Yes, you need some kind of comparison!

 

What about this:

  1. Sort that table by the "Date" column.
  2. Get subsets of the whole array for each individual "Date" (much easier now after sorting the table!).
  3. Create an Excel worksheet for each of the subsets…

To sort the array you will find a VIM in the array functions palette, atleast in LV2020 (and maybe starting from LV2017). For (much) older LabVIEW versions you will find similar VIs in OpenG…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 7
(1,137 Views)

Hi GerdW,

 

Thanks for the prompt reply! I have sorted it according to dates already but the problem is the repeated dates. I think it would be better if i attach the whole vi and the error. 

Download All
0 Kudos
Message 3 of 7
(1,124 Views)

Hi jvvvv,

 

sorting the same array in the loop again and again is just Rube-Goldberg.

You also forgot to implement point 2 of my previous suggestion!

 

(You also should not use a "csv" file as template when you want to create an Excel workbook containing several worksheets…)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 7
(1,112 Views)

Hi GerdW,

 

I have done all of the suggestions you provided. However, I am not able to achieve what I want, which is to create a sheet for each date while eliminating the error caused by repeating. Do pardon me as I am still new to LV.

0 Kudos
Message 5 of 7
(1,106 Views)

Hi jvvvv,

 

you don't use ArraySubset to get a block of rows of the same "Date" value until now!

 

You are using Sort2DArray.VIM twice: what is the result of those operations?

After sorting the 2D array you should use the "Date" column to determine each block of rows for each of the "Date" values:

  1. Get the first "Date" value.
  2. Search for the first item in the column unequal to this value: Now you know where the "Date" starts and ends.
  3. Use this information for ArraySubset to get a subarray for just this one "Date" value.
  4. Save the block in its worksheet.
  5. Repeat from step 1 for each "Date" value!
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 7
(1,091 Views)

Hi GerdW, 

 

After I have sorted it by the date columns, I have to put the output through an index array of column 2 to get the date array. Then after that, I have to do the 5 steps you mentioned. I am trying to do that using while loop, end the loop when the date is different and repeat till end of array. 

0 Kudos
Message 7 of 7
(1,033 Views)