01-21-2016 06:56 AM - edited 01-21-2016 06:57 AM
Hi,
I have problem with my program.
I need to delete empy lines from my txt file.
This file is look like:
## Normalised capacitance data file ## Capacitance model: Parallel (K = 3.0) ## Created by: ECT32v2 for Win32 Beta2.25 (Jul 10 2003 01:54:24) ## Source: rec_flow_f45_v800_n2.bcp ## Description: Contents of capture mode buffer ## Date: 12:04:43 GMT Standard Time, 29Mar04 ## Electrodes = 8, Measurements = 28 ## Data for Plane 1 ## frame 1 (0 msec) 0.006 -0.001 -0.004 -0.002 -0.028 -0.002 0.031 -0.008 -0.005 -0.007 -0.024 0.005 0.004 -0.014 -0.002 -0.011 -0.004 0.002 -0.008 -0.003 0.004 -0.003 -0.011 0.002 0.001 0.004 0.005 0.008 ## frame 2 (10 msec) 0.005 -0.002 -0.008 -0.002 0.006 0.011 0.023 -0.008 -0.004 -0.004 -0.010 0.001 0.003 -0.007 -0.001 -0.012 0.007 0.008 -0.015 -0.004 0.002 0.001 -0.007 -0.002 0.001 0.008 -0.002 0.005
I want to delete all empty lines, lines which contain "##"
I try like attachment but it doesn't work.
How can I do this?
Regads,
Sorry for my english
Solved! Go to Solution.
01-21-2016 07:44 AM
You need two tests. One for the empty lines and another for the lines starting with ##.
I converted the string to an array of strings. Then test each element of the array. Using conditional indexing, I build an output array of strings containing only the data elements. Then I convert that back to a single string.
Lynn
01-21-2016 07:46 AM
@piotrek0492 wrote:
Hi,
I have problem with my program.
I need to delete empy lines from my txt file.
This file is look like:
## Normalised capacitance data file ## Capacitance model: Parallel (K = 3.0) ## Created by: ECT32v2 for Win32 Beta2.25 (Jul 10 2003 01:54:24) ## Source: rec_flow_f45_v800_n2.bcp ## Description: Contents of capture mode buffer ## Date: 12:04:43 GMT Standard Time, 29Mar04 ## Electrodes = 8, Measurements = 28 ## Data for Plane 1 ## frame 1 (0 msec) 0.006 -0.001 -0.004 -0.002 -0.028 -0.002 0.031 -0.008 -0.005 -0.007 -0.024 0.005 0.004 -0.014 -0.002 -0.011 -0.004 0.002 -0.008 -0.003 0.004 -0.003 -0.011 0.002 0.001 0.004 0.005 0.008 ## frame 2 (10 msec) 0.005 -0.002 -0.008 -0.002 0.006 0.011 0.023 -0.008 -0.004 -0.004 -0.010 0.001 0.003 -0.007 -0.001 -0.012 0.007 0.008 -0.015 -0.004 0.002 0.001 -0.007 -0.002 0.001 0.008 -0.002 0.005I want to delete all empty lines, lines which contain "##"
I try like attachment but it doesn't work.
How can I do this?
Regads,
Sorry for my english
Hello piotrek0492,
The lines that contains ## are not empty, so what would you like to do?
Michel
01-21-2016 08:06 AM - edited 01-21-2016 08:08 AM
@johnsold wrote:
You need two tests. One for the empty lines and another for the lines starting with ##.
This will work but not necessarily for just lines starting with ## but also if ## appear in between (very unlikely given the file format). If that is a possibility, you have to use a regex.
^ will ensire it is checked at the beginning.
01-21-2016 08:48 AM
First of all, please do us the courtesy of submitting executable code (attaching a VI is the easiest way to do this) so that we don't have to recreate your program ourselves to test it.
Have you taken the freely-available LabVIEW tutorials and spend a few hours learning the basics of LabVIEW? Have you programmed up the example code in the Tutorials for yourself and tried making small changes to get it to do other things?
Sometimes it is helpful to think about the problem before jumping into coding. Here's how I see your task:
Do you see any "logical structure" to this description? Are there obvious loops, obvious "branch" decision points? What LabVIEW constructs handle loops? How do you read lines of text? How do you selectively output lines of text?
Bob Schor
01-21-2016 09:07 AM
Good advise has already been provided.
But just for fun here is a couple of loops that will perform parsing functions that may work depending on your desired outcome.
Yes there are other ways but you can trace through the code maybe pick up something along the way.
Good luck
01-21-2016 04:07 PM
01-22-2016 09:36 AM - edited 01-22-2016 09:37 AM
Ben thanks for the example. Somehow I had missed the setting that allowed the expresion search. Your example sent me back to the help files to figure it out. I have modified my first code to show the method I hope I have the explaination correct. Not trying to do someones homework for them but for those who need a quick start perhaps this will help someone else along the way.
01-22-2016 09:41 AM
01-22-2016 09:44 AM
thanks for all the answers.
It helped me in solving tasks and accede to the further stages of the work.
Regards