LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Read value and string from file

Hi all,
 
I have seen some post on this question but I have a bit of confusion, My task is, I want to read some values and corresponding string from the file
Lets say,
 
2.2   4.3    Red
3.4   2.1    Green
1.1   4.4    Blue
 
I stored this values in one of excel file so i want to read these values from file and I have to compare these values with the value I take from DAQ board,
for example i measure the value from DAQ board like 2.2   4.3 so I have to find match from above table and the relult should be like 2.2  4.3  Red. 
 
Thank You
0 Kudos
Message 1 of 10
(3,382 Views)
Hi N.K. You want to use Read From Spreadsheet File.vi located in the File I/O palette - it looks like quite a scary .vi but the help for it is good so you should be able to tailor it for your spreadsheet. Also you might want to take a look at the Configuration VI's also in File I/O - they can be very useful. You'll have to make sure your excel file is in the correct format by saving as a delimited file of some sort i.e. .csv.
 
David C
David Clark
CLA | CTA
IDEX Biometrics UK Ltd
Hampshire, England
0 Kudos
Message 2 of 10
(3,372 Views)

Thank you

 I have tried that Read From Spreadsheet File.vi it is just reading values i mean numerics not string like green or red, So i m thinking how to read string and values and then compare with valuses i take from DAQ board. Reply me if you have any idea... 

Message 3 of 10
(3,362 Views)
If you make a copy of the Read From Spreadsheet File.vi and open the copy, you can modify it to read an array of strings. Then convert the numeric strings to numeric values and keep the text as strings. Be sure to use a copy and save it with a different name so other programs using the original VI do not fail.

Lynn
Message 4 of 10
(3,354 Views)

Look at the instructions on the diagram of Read From Spreadsheet file for the modifications required to change it to read strings. When you do this, you will get a string array (2D and 1D) back. You can then convert the columns with numbers with something like Fract/Exp String to Number. When you make the changes to Read From Spreadsheet, be sure to save it with a new name and in a different location. If you get really ambitious and you have the pro version of LabVIEW, you can create a polymorphic VI that will do either.

Message 5 of 10
(3,355 Views)

Thank you for taking interest but I realy dont understand both solutions could you explain it in littel bit in breaf to be honest I am new to LabVIEW..

 

Thank You

Message 6 of 10
(3,349 Views)
Also I am attaching a example VI and Excel file but in this VI it just showing numeric values.
Download All
Message 7 of 10
(3,343 Views)
I can't open your vi since I don't have LV8 yet.  But here is the modified Read From Speadsheet File modified to accept strings instead of numerics, as Dennis was talking about.  For the numeric parts of the spreadsheet, convert those array elements to numerics with the Fractional String To Number function as such:
 

Message Edited by tbob on 03-09-2006 01:48 PM

Message Edited by tbob on 03-09-2006 01:48 PM

- tbob

Inventor of the WORM Global
Download All
Message 8 of 10
(3,337 Views)

Before you read the instructions below, you really, really should check into some of the resources for learning LabVIEW. Go to http://www.ni.com/devzone/lvzone/fundamentals.htm and look into all of the various options for official classes and web tutorials. The modifications required are some of the simplest tasks in LabVIEW and should be considered basic skills that you need to write and debug you own program.

Okay, open Read From Spreadsheet file by first dropping it to a diagram and double clicking the icon. Go to the diagram and on the control labeled "type (empty)", right click and select Show Control. On the front panel, right click on one of the numeric indicators in the "all rows" 2D array indicator. Select Replace and select String Indicator from the Controls palette. Do exactly the same thing with one of the numeric indicators in the "first row" 1D array indicator. Do exactly the same thing on the (now visible) "type (empty)" control. Right click on "type (empty0" and select Hide Control. Go to the string control labeled "format (%.3f)" and change to %s. Right click on this control and select Data Operations>Make Current Value Default. These are all of the changes requied. You now have to save the VI. Go to File>Save As and select a new name (i.e. Read Strings From Spreadsheet File) and save it to a new location. Do not save it in the same folder. You can save it in in the User.Lib folder or any other place on your local drive.

Message 9 of 10
(3,330 Views)
Just one teeny tiny little thing to add to Dennis's instructions.  Change the label "format (%.3f)" to "format (%s)".  This way, when you hover the wiring tool over that terminal in the subvi, the correct label will appear as a tip strip.
- tbob

Inventor of the WORM Global
Message 10 of 10
(3,310 Views)