LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Parsing a long string to extract specific data

Solved!
Go to solution

The attached VI ( LV12) describes my problem. 

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 1 of 10
(3,595 Views)

It is unusual (but, I suppose, OK) to pose a problem in the VI, rather than in the post!  But at least you included a VI.

 

For those who are interested, the problem involves parsing part of a long input string:

$Time:2.4652[h];ISO4um:23[-];ISO6um:22[-];ISO14um:18[-];ISO21um:15[-];SAE4um:12[-];SAE6um:12[-];SAE14um:12[-];SAE21um:12[-];NAS:12[-];GOST:17[-];Conc4um:53651.37[p/ml];Conc6um:35405.87[p/ml];Conc14um:1944.37[p/ml];Conc21um:245.25[p/ml];FIndex:242964[-];MTime:60[s];ERC1:0x0000;ERC2:0x0000;ERC3:0x0000;ERC4:0x0300;CRC:¼

 

The OP seemed to be able to isolate the substring "ISO4um:23[-];ISO6um:22[-];ISO14um:18[-];" and wanted a way to get the three values after the colons, here 23, 22, and 18, with the proviso that they would be numbers from 0 to 23.  For this sub-problem (and for many other String Parsing problems), Scan from String is the function I prefer.  Here I show how you can use Scan from String and its partner, Format into String, to take 3 values from 0 to 23, form an ISO string such as shown above, and then parse it into the three values again (allowing you to test that the function "does what you want" (it will almost always "do what you tell it to do", but that's not always "what you want" ...).  Notice that the same Format string can create the ISO String and take it apart.

Bob Schor

0 Kudos
Message 2 of 10
(3,567 Views)

Thanks Bob. Looks to be logical.

DId you attach the solution VI snippet ? I just see a back x mark indicating a broken link ... can you repost the snippet ?

 

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 3 of 10
(3,551 Views)

 OOPS!  And, to make it worse, I did this last night on my laptop at home.  But not to worry -- I'll get it back, and will post it as both a Snippet and as an attached VI.  It appears to me that you might be using LabVIEW 2012, which I happen to have installed in my work machine here, so I'll even try to use that Version for you ... I'll be back shortly.

 

Bob Schor

0 Kudos
Message 4 of 10
(3,521 Views)

@Bob_Schor wrote:

 OOPS!  And, to make it worse, I did this last night on my laptop at home.  But not to worry -- I'll get it back, and will post it as both a Snippet and as an attached VI.  It appears to me that you might be using LabVIEW 2012, which I happen to have installed in my work machine here, so I'll even try to use that Version for you ... I'll be back shortly.

 

Bob Schor


No issues.. so kind of you !!  I am ok with LV2015 also if that helps ....

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 5 of 10
(3,513 Views)
Solution
Accepted by topic author MogaRaghu

So embarrassing ...  Here is a LabVIEW 2012 Snippet, along with the LabVIEW 2012 VI.

Parse ISO 2012.png

Recall this is a "Proof-of-concept" VI -- the left "Format Into String" takes three 0..23 values and formats it into the ISO string that you need to parse, while the second "Scan from String" parses that String and should return exactly the same values used to create it.  And (fortunately), it does.

 

Bob Schor

Message 6 of 10
(3,510 Views)

@Bob_Schor wrote:

So embarrassing ...  Here is a LabVIEW 2012 Snippet, along with the LabVIEW 2012 VI.

Parse ISO 2012.png

Recall this is a "Proof-of-concept" VI -- the left "Format Into String" takes three 0..23 values and formats it into the ISO string that you need to parse, while the second "Scan from String" parses that String and should return exactly the same values used to create it.  And (fortunately), it does.

 

Bob Schor


Hey, Bob - don't forget that the forum destroys the magic in the snippet ever since the forum "upgrade" so you have to upload the png file if you want it to retain its magical properties.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 7 of 10
(3,503 Views)

@billko wrote:

Hey, Bob - don't forget that the forum destroys the magic in the snippet ever since the forum "upgrade" so you have to upload the png file if you want it to retain its magical properties.

Which is why I also attached it as a VI.  But that is so annoying -- the whole point of the Snippet was to allow you to send a VI as an Image and include "magic" ...  If the LabVIEW Forum can't get it right, why is the feature even there?

 

Bob Schor

0 Kudos
Message 8 of 10
(3,486 Views)

@Bob_Schor wrote:

@billko wrote:

Hey, Bob - don't forget that the forum destroys the magic in the snippet ever since the forum "upgrade" so you have to upload the png file if you want it to retain its magical properties.

Which is why I also attached it as a VI.  But that is so annoying -- the whole point of the Snippet was to allow you to send a VI as an Image and include "magic" ...  If the LabVIEW Forum can't get it right, why is the feature even there?

 

Bob Schor


I was so upset by this revoltin' development that I considered writing a strongly-worded letter to the moderator.  😉

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 9 of 10
(3,483 Views)

Thanks Bob. Using the idea you provided I completed the required code to pull out the data I want from the long string. I can now make this into a Sub VI.  Of course the way I have coded to strip out the required sub string from the raw data looks a bit odd, but does the job so will leave it ...

 

Attaching the final code. 

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 10 of 10
(3,465 Views)