LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to retrieve specific data from a text file

Solved!
Go to solution

Hi, everyone

 

For my project it is required that a parameter file is read at the beginning, in order for certain variables to be initialized with specific values that change with the user.

 

At the moment, the way it is done is the following:  The values at a specified sequence in a text file are read and saved in an array and the elements of the array are retrieved according to their index.

 

The problem with this implementation is, that if for some reason the format of the file changes, e.g. we want to use a parameter file from a previous version of the program that has the values for the same variables but in a different order, the only way to have the right values for the parameters is to change everything accordingly, which is really time wasting.

 

Could someone suggest a different implementation that would make the reading of the different values independent from their order in the file, e.g. by scanning the file for specific strings and reading the value after the string?

 

Thank you very much.

 

P.S. I have  attached a screenshot of the routine I am using now.

0 Kudos
Message 1 of 3
(3,623 Views)
Solution
Accepted by topic author panagiov

Hi panagiov,

Find attached Folders.

Method 1: in this you can search for each variable separately. You can use "Config file vis" to get all keys(Variables) at once and then you can use for loop to get their values. Or you can access individual values as shown in this code.

Method 2: here you will get all data at once. You will get Variable and Data (2D array) You need to search variables as and when required.

 

I hope you will understand these methods.

 

Best of luck Smiley Happy

Gaurav k
CLD Certified !!!!!
Do not forget to Mark solution and to give Kudo if problem is solved.
Download All
Message 2 of 3
(3,614 Views)

Thank you so much!!! Smiley Very Happy

0 Kudos
Message 3 of 3
(3,590 Views)