LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to read data from spreadsheet as a look up table

Hello Can anybody please help me out in this..??

I want to read data from a spreadsheet file as it is a look up table.

 

I want to create a program which lets the user enter an element which is be found in the data in the spreadsheet file and gives back the number which is to the adjoining column of the element in the spreadsheet file.

Example i have the following data in spreadsheet file:

Range  Count
2              10

4              49

6              60

Etc.

If i enter 2 to search the data in the spreadsheet file, i do expect the program replies back with the answer 10 and so on...

 

Can anyone please help out...

 

Thanks in advance...

 

0 Kudos
Message 1 of 18
(3,427 Views)
What exactly have you tried so far? Is this a csv file that you can use the Read From Spreadsheet File or native Excel? Either way, after you have read the file, you would have a 2D array and then just a Search 1D Array on column 0. Use the returned value and index array on column 1.
0 Kudos
Message 2 of 18
(3,425 Views)

Example_VI.png

0 Kudos
Message 3 of 18
(3,413 Views)

@apok wrote:

Example_VI.png


Why autoindex the output?  You should only have 1 output.  Besides, the Search 1D Array is simpler (no loop needed).


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 18
(3,400 Views)

@crossrulz wrote:

@apok wrote:

Example_VI.png


Why autoindex the output?  You should only have 1 output.  Besides, the Search 1D Array is simpler (no loop needed).


might be 2 cases associated with that # and how does using a for loop make it any less simpler? is this a matter of opinion....wonder what the bench marks are?

0 Kudos
Message 5 of 18
(3,393 Views)

Yes i have tried the data to be read using a csv file.

I even tried reading the data using a 1d array and sesrching the index so as i can link it with other part but the reult i found was always a 0 or -1.

0 Kudos
Message 6 of 18
(3,370 Views)

apok wrote: might be 2 cases associated with that # and how does using a for loop make it any less simpler?

Both methods are flawed. Tim's solution will not correctly work if no match is found.

 

The FOR loop version will return an array (possibly empty). Since the requred output is a scalar, it also does not solve the problem.

0 Kudos
Message 7 of 18
(3,365 Views)

hello apok

 

can u just tell me which block have u used??

0 Kudos
Message 8 of 18
(3,355 Views)
If your code does not work, then attach the VI/block diagram image and the data file.

The posted examples are either snippets or have all functions labeled. Your request for 'blocks' does not make much sense. And please use full words.
0 Kudos
Message 9 of 18
(3,345 Views)

i am attaching the vi as zip file

0 Kudos
Message 10 of 18
(3,340 Views)