From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
04-08-2015 01:33 AM
Anyone have an example vi to "grep" from a text file for relevant strings, then write the reformatted strings to another file?
Basically looking to create a vi to function like wingrep. . .
04-08-2015 02:20 AM
Hi msp,
basically you use File functions to read your textfile into a string. Then you use String functions (like MatchPattern) to search for your strings of interest. You collect your data in an appropriate data structure (like an array or a cluster) and you will use other file functions to create your "another file"…
What have you tried so far? Where are you stuck?
04-08-2015 02:43 AM
Hey, thanks for your time!
Yes, I guess you could say I'm stuck! I've tried match pattern, match regular expression, scan from file etc. . .
I would have an example but I was disgusted and deleted them to start over. Reading and writing from text files seems to be pretty straight-forward, I seem to be stuck on pulling out the lines of text that I want, and reformatting it to a new file.
Some of the log files will be hundreds of lines. . .I seem to be hung up on reading all the lines, my vi's seem to stop at the first line.
;-(
04-08-2015 03:01 AM
04-08-2015 03:42 AM
Greetings,
Here's a short example of my logged data:
I would like to format the log data to show something like this:
20150121 202454 Print Pass # 346 Facets: 20875 Start facet: 10
20150121 202450 54c07b92 DEB I PSU:0x20a0000 10b7006d 0 printControl.cpp 3820 VG ready timeout detected this pass
20150121 202454 54c07b96 DEB I prt:0x20a0000 Print Pass # 346
. Stripe: 173550720.0000 (nm) 21539235.4440 (LMS) Scan: 233503952.0000 (nm) 30119199.0020 (LMS)
. Facets: 20875 Start facet: 10
.
20150121 202500 54c07b9c DEB I PSU:0x20a0000 10b7006d 0 printControl.cpp 3820 VG ready timeout detected this pass
20150121 202505 54c07ba1 DEB I prt:0x20a0000 Print Pass # 347
. Stripe: 142094760.0000 (nm) 46989538.1471 (LMS) Scan: 233766032.0000 (nm) 30333530.7008 (LMS)
. Facets: 44971 Start facet: 18
.
20150121 202515 54c07baa DEB I PSU:0x20a0000 10b7006d 0 printControl.cpp 3820 VG ready timeout detected this pass
20150121 202516 54c07bac DEB I prt:0x20a0000 Print Pass # 348
. Stripe: 142093440.0000 (nm) 46990591.7200 (LMS) Scan: 234028240.0000 (nm) 30545677.4944 (LMS)
. Facets: 45035 Start facet: 10
.
20150121 202526 54c07bb5 DEB I PSU:0x20a0000 10b7006d 0 printControl.cpp 3820 VG ready timeout detected this pass
20150121 202527 54c07bb7 DEB I prt:0x20a0000 Print Pass # 349
. Stripe: 142094760.0000 (nm) 46989509.3554 (LMS) Scan: 234290320.0000 (nm) 30757720.5475 (LMS)
. Facets: 45035 Start facet: 18
.
NOTE: I seemed by having some issues with the match regular expressions function. It didn't like the null characters. . .
04-08-2015 04:15 AM
04-08-2015 01:04 PM
Hey, thanks!! Great example. Especially if I can get it to work for me.
LabVIEW: Scan failed. The input string does not contain data in the expected format.
Looks like its hanging up at the Scan From String Function. I clearly messed something up. . .
I'll keep staring at it for a while. . .
04-08-2015 06:27 PM
Greetings again,
Still struggling! ;-( Maybe I wired up the false condition wrong in the case structure? I'll attach the vi for your reference.
Thanks for all the help. . . much appreciated!
MSP
04-08-2015 06:43 PM
Yes, in the false case, you wired "c" to the shift register that's collecting your "Filtered rolling". C is going to be empty in the last itteration because the match pattern won't be found. This clears out your "filtered rolling" shift register. You can see this if you turn on highlight execution and probe around. You should wire the incomming shift register back out in the false case because you don't want to make any changes to the "filtered rolling" buffer. Also, you appear to be missing a space after the period in
. Facets: %d Start facet: %d
Lastly, you probably want to print a new line at the end of
Print Pass # %d Facets: %d Start facet: %d
04-09-2015 01:41 AM
Hi msp,
the next time you want to make comments on the name of functions you use in your VI: simply right-click them and show their label…
But better get rid of such comments and show the context help window. It also shows the name of each function in your VI!