ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Split multi line string where next line changes

Solved!
Go to solution

Hello

The attached screen capture is a multi line string of test results. Each line of the string consists of a date, time and a few numbers which represent the results.

How can I split this string into 2 strings at the arrow indicated, which is where there is a gap of more than 5 minutes between the timestamps?

Thanks

0 Kudos
Message 1 of 9
(5,731 Views)
Solution
Accepted by topic author tone5

Here's a start.  Scan the time and subtract it from the previous line.

 

snip.jpg

 

 

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

Message 2 of 9
(5,700 Views)
Solution
Accepted by topic author tone5

To add on to 

 

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


Message 3 of 9
(5,652 Views)

I have maneged to implement this and get it to work, even I don't yet fully understand the string format notation. Many thanks for the suggestion.

0 Kudos
Message 4 of 9
(5,617 Views)

The format is a timestamp because it uses "%<" and ">T" to surround the sub-format that defines the timestamp within the string.

Within the timestamp format, there are instances of hour/minute/second/etc values that it looks for within the string. Everything with a "%" in front of it is a numeric value. Everything else is a delimiter specific to the string.

 

Simple Example:

String: "4:30"

Format String: "%<%H:%M>T"

It uses the colon in the format string to understand where a colon would be found in the timestamp.

Alternatively, you could use "0430" and "%<%H%M>T" and get the same result (but only if the "04" is two digits instead of one)

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 5 of 9
(5,602 Views)

Thanks James

I'm struggling to understand what the "%p" does in "%<%d/%m/%Y %H:%M %p>T"

The Labview help suggests that the %p defines the precision. However when I change the %p to %.2p, or any other value instead of 2, the precision of the result does not change.

The reason I'm looking at this is because I would like the resulting string to look like "dd/mm/yyyy hh:mm:ss", not "dd/mm/yyyy hh:mm:ss.000" i.e. I don't want the 3 decimal places after the seconds.

Am I on the right track in thinking that %p controls the precision of this, or is it done differently for a time vaule?

 

0 Kudos
Message 6 of 9
(5,537 Views)

%p reads the AM/PM part of the timestamp

 

I usually look here to decode this stuff:

 

snip.jpg

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 7 of 9
(5,512 Views)

@tone5 wrote:

The reason I'm looking at this is because I would like the resulting string to look like "dd/mm/yyyy hh:mm:ss", not "dd/mm/yyyy hh:mm:ss.000" i.e. I don't want the 3 decimal places after the seconds.

Am I on the right track in thinking that %p controls the precision of this, or is it done differently for a time vaule?

 


"resulting string" What resulting string?

From jcarmody example, you have strings that are converted to a Numeric Time Stamp (number of seconds)

 

Are you talking about a Time Stamp Control that you have placed on your VI?

TimeFormat.png

 

I think you will also need to use the following format string

%<%m/%d/%Y %H:%M.%S>T

I assume the decimal point in your time strings does not mean fractional minutes, but seconds

Omar
Message 8 of 9
(5,493 Views)

Thanks Omar and jcarmody; that's useful information.

0 Kudos
Message 9 of 9
(5,425 Views)