LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to read from text file?

I would like to read data (frequencies) already written in a text file. I will need read these frequencies one at a time to set the function generator (as part of my data acquisition application), acquire data that is in turn written to a file and then go back and read the next frequency from the file to repeat the process again. I also have another idea of doing the same, which is read all the frequencies from the text file and populate a table and a frequency value is picked from the table each time to go through the process mentioned above.
 
Can anyone suggest the following: (1) How to read from a text file, (2) What could be the most efficient way of solving my above problem.
 
I am a new LabVIEW user and any help will be appreciated.
0 Kudos
Message 1 of 4
(3,269 Views)

Hi Research,

An easy method would be to either populate a table or an array and pick the value needed without re-opening the file.  You can use the "Read Characters From File.vi", which is located under "File I/O" in the Functions Palette.  You can parse the content of the text file by using the vi's located in the Function Palette under "String" and "Array" if you wish to go the array route.  The advantage of using an array (or table) is that it can be wired elsewhere in your vi or sent to other vi's or sub-vi's.  Especially if you only read from the text file.

Regards,

Ray 

Message 2 of 4
(3,268 Views)

Ray,

I am using LabVIEW 8.0 and I could not find "Read characters from file.vi" under File I/O menu. Has this been replaced with a different name from previous versions. And how does one parse a string or read values from a table once it has been populated.

0 Kudos
Message 3 of 4
(3,254 Views)

Hi Research,

Depending on the format of the data file, there are a few options for reading it.  If it is tab delimited, you may want to use the Read from SpreadSheet File VI which will read the file into an Array.  You can then use the Index Array VI to pull out individual entries.  If the files is ASCII but not tab delimited, you could use the regular Open File and Read File VIs.  You can either read the file out piece by piece, or read the entire file into a string and then use the Match Pattern VI to parse out the different elements (there are actually many ways to do this - check out the Strings subpalette). 

Since you're new to LabVIEW, you may want to check out these resources:
Getting Started with LabVIEW

I hope this helps!  Let us know if you have more questions,
Megan B.
National Instruments

Message 4 of 4
(3,224 Views)