Showing results for 
Search instead for 
Did you mean: 

Help with trying to figure out how to sort data from a text file in labview

I'm working on a project that needs to be able to sort through the text file and place the correct words into string boxes. What we are trying to do is use a search and split string but we cant quite figure it out. We want it to come from one text file and sort into 10 different places. For example we want to because for lab view to read the sentence; Patient has a body weight of 150 lbs. and  a height of 66in. and then have strings on the block diagram with height and weight and when we run it only 150 lbs would be in the box for weight and then only 66 in would be in the box for height and so on. there are more sentences in the text file but that was just to example what we want to do . I can attach our code right now and the txt file we are working with if anyone can help.

Download All
0 Kudos
Message 1 of 3

I would use regular expressions and not worry about splitting the string. Simply use your various regular expressions over the entire string every time. For example, to find the body weight I would use "weight.*(\d+)\s*(\w*)$". I would use the VI Match Regular Expression and set the Multiline input to true. Expand the Match Regular Expression node to show the outputs. The first will be the weight, the second will be the units. If no units are provided the second output will be an empty string. Create the other regular expressions for the other data you are looking for. This will be more robust since it will work regardless of the order thing appear in the file.

Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 2 of 3

Mark's suggestion is about as good as possible but be aware that slight or small variations in the spelling will introduce issues.




There is a faint voice in my memory that still remembers someone possibly on Info-LabVIEW  posting many years ago that LabVIEW is good for many applications but when it comes time to write a word-processor, there may be better options.





Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 3 of 3