LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading spreadsheet (txt with \n)

Hi

I used Read From Spreadsheet.vi to read from my data file. Can anyone advise me which function should I use to extract the subelement out? Is there any example code that extract information from data file and insert it into a table. I need to use the sub-element of the array to send out output signal.

I tried to use while loop but I am lost.

THanks
0 Kudos
Message 1 of 9
(3,461 Views)
try looking at the index array or the array subset functions. These functions will allow you to parse out infomation from an array using its row and column indices. These are located under the array pallette. If you bring up the context help window (ctrl-h) and hover over these functions you can get detailed help on how to use them. Hope this helps.
BJD1613

Lead Test Tools Development Engineer

Philips Respironics

Certified LV Architect / Instructor
0 Kudos
Message 2 of 9
(3,454 Views)
Hi

Thanks for the reply.

I tried to use Index Array but I need to parse out sub-element with time delay. Do I need to use loop?

Thanks
0 Kudos
Message 3 of 9
(3,450 Views)
Hello jw81,

why do you need a delay?
Do you need the delay between reading the spreadsheet data and the "Index array"? If so, you probably change the data array by using loacal variables (or similar) and that is no good dataflow programming...
And to use a loop for waiting is not so good, just try the different timing functions from the time & dialog palette.

Best regards,
GerdW
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 9
(3,444 Views)
Hi

I dont know delay when reading the data. I am doing data reading from txt file to VI.

Then the user can execute signal sending (the signal sent out depends on the data from the txt) by clicking a button.

Here is what I need to do in brief:

Txt file (voltages) -------> Display in a table or listbox in VI ----(after being execute)---> voltage signal is sent out (with delay).

From the example in NI Zone, I am able to use Read from Spreadsheet and Index Array to get all the voltages from the text to the table. But I still don't know how to extract the voltages from element 0 to element n. Any function can do that?

Thanks
0 Kudos
Message 5 of 9
(3,441 Views)
Hello jw81,

use "Array subset" to extract element 0 to n from an array.
In the case of an 1D array just wire n+1 (element 0 to n is n+1 elements!) to length and let index unwired (starts automatically with 0). Then you get your subarray. If you need them one by one you have to use "Index array" for each element you need or a loop (perhaps with autoindexing enabled).
For 2D arrays (or more dimensions) you have to give values for all dimensions (index and length).

Best regards,
GerdW
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 6 of 9
(3,436 Views)
Thanks GerdW,

Do I need to use the Array Subset within a loop? Do you recommend while or for loop?

Thanks
0 Kudos
Message 7 of 9
(3,430 Views)
Hello jw81,

sorry, but I can't answer your questions... It really depends on your programming problem.

For "Array Subset": Do you only need one element at a time or more? Do you need them one after the other or in a special order?

For While vs. For: Do you want to process all array elements (-> For-Loop)? Do you want to have the possibility to abort the loop before all elements are processed (or to abort on an event independent of your data array) (-> While-Loop)?

Hope this helps,
GerdW
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 9
(3,414 Views)
Thanks I have solved my problems today.
0 Kudos
Message 9 of 9
(3,411 Views)