LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading excel file, saving the 3x5 array data to temporary variable and changing the array elements if needed.

Solved!
Go to solution

Hi, everybody. Please, help.

 

I need to read from an excel file the 3x5 array and write it to a global variable. Then I should be able to change the element (or elements) if needed of global variable. The aim is to be able to replace the elements of array taken from the excel file and use it in somewhere else. 

 

Attaching the code that I wrote. Any kind of help is appreciated.

 

0 Kudos
Message 1 of 12
(1,611 Views)

You did not attach any subVIs and the code looks like it is full of race conditions and makes very little sense.

 

You are reading from the global (two places, redundant!) and writing to it in (at least) one place in parallel. (No way to tell what happens first and if you are also writing to it on one of the subVIs)

 

Where is "somewhere else"?

0 Kudos
Message 2 of 12
(1,572 Views)

You appear to be using some third-party code to read from Excel, rather than NI's Report Generation Toolkit.  It is difficult to "guess" what these unknown functions do, and what they might return.

 

Why don't you write a little routine that returns a 3x5 array (maybe 1, 2, 3 \\ 4, 5, 6 \\ 7, 8, 9 \\ 10, 11, 12 \\ 13, 14, 15) to replace the Excel code (that we can't see nor understand) and try to save this array to a temporary variable and change it as you want?  Once you get this to work, you only have to figure out (with a separate little piece of code) how to read in the data from Excel.

 

Bob Schor

0 Kudos
Message 3 of 12
(1,549 Views)

Hi, Bob

 

Actually, excel part is not so important. My problem is with changing array elements if needed.

0 Kudos
Message 4 of 12
(1,544 Views)
Solution
Accepted by topic author Armagedon

Hi Armagedon,

 

why do you need this global variable at all?

 

This is the core of your VI without the global:

 


@Armagedon wrote:

My problem is with changing array elements if needed.


You already use those ReplaceArrayElement functions, so what is your problem?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 5 of 12
(1,533 Views)

Hi Armagedon,

Then in that case you need to use the 'in place element structure' to replace the elements in a efficient way..

I just pasted a snippet below. Hope this helps.

srikrishnaNF_0-1601399652048.png

 

Regards,
Srikrishna


0 Kudos
Message 6 of 12
(1,527 Views)

Hi srikrishna,

 


@srikrishnaNF wrote:

in that case you need to use the 'in place element structure' to replace the elements in a efficient way..


Why does he "need to" use that?

Why do you think this will be more efficient than a simple ReplaceArrayElement node?

Best regards,
GerdW


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

@srikrishnaNF wrote:

Then in that case you need to use the 'in place element structure' to replace the elements in a efficient way..


As Gerd already hinted, "Replace array element/subset" operates fully in-place and is equally efficient. It is also more flexible because it can also be used to replace entire rows or columns. Please don't overcomplicate the discussion. The IPE has useful applications, but this is not it.

0 Kudos
Message 8 of 12
(1,509 Views)

@GerdW,

 

You are awesome. Thanks a lot.

But, there is a problem that I could not figure out why it happens.

For example, when I am changing the element to one in 2x0 then all the column elements until 2x0 immediately becomes zero (0x0 and 1x0).  

 

However, I am trying to be able to change elementwise. As you understand I am completely new to LabView. Please, help.

0 Kudos
Message 9 of 12
(1,495 Views)

Then you must have done something wrong.

 

Attach your latest VI so we can see what that was and tell you how to fix it.

0 Kudos
Message 10 of 12
(1,465 Views)