LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how do I delete empty string lines in between pertinent data?

Solved!
Go to solution

I am having trouble with removing empty string lines from my final data output.  I know it is simple to do, but I'm stuck in the same train of thought.  The file is a converted hex file that is written to a series of records.  Converted lines that result in all F's as the data need to be deleted and the # of records adjusted accordingly.  I have the code to take the file, convert it, remove all records with F's, and adjust the # of records, but I'm left with a gap in my file that no matter my approach I cannot remove the empty string spaces consistently.  I have attached the file with the spaces and the goal is to remove the spaces in between the blocks of code, and the spaces will not always be on the same lines.  Thanks for any help.  If needed I can attach the code I've already developed if needed.

 

Darrick 

0 Kudos
Message 1 of 7
(9,943 Views)
Solution
Accepted by topic author DarrickZ

You could read the file line by line, and write it back out only if the length of the string <>0.  (or perhaps <>1 in case the line feed character shows up in the string for an empty line.)

 

However,  there is probably a way to modify whatever code you have now so that it doesn't write out the empty lines.  Without seeing that code, it is hard to help.

Message 2 of 7
(9,920 Views)
The code is extensive and has not been refactored but I will post it.  If you have any questions then ask away.  I attached the zip file with the main VI and supporting VI's.  The main VI is titled FB_Update_Hdr Updated 2nd Draft.vi
0 Kudos
Message 3 of 7
(9,912 Views)

It isn't pretty but here is a way. Note that it resizes an array in a loop which is generally a bad thing to do, but in this case it is only making the array smaller. The code is in 2009 (snipit sort of gives that away).

 

steve

 

 

----------------------------------------------------------------------------------------------------------------
Founding (and only) member of AUITA - the Anti UI Thread Association.
----------------------------------------------------------------------------------------------------------------
Download All
Message 4 of 7
(9,889 Views)

Or you could try :

 

 

Text replacer.png

 

This will replace anything or things you want and count the total number of replacements made

Since you only want to remove empty lines search for "\n\n" and replace with "\n"

Message Edited by Jeff Bohrer on 10-27-2009 10:26 AM

"Should be" isn't "Is" -Jay
0 Kudos
Message 5 of 7
(9,863 Views)

OOPS (should have tested that first)  substitute the following :

 

oops.png

 

Thanks for the confidence though!

Message Edited by Jeff Bohrer on 10-27-2009 10:41 AM

"Should be" isn't "Is" -Jay
Message 6 of 7
(9,849 Views)

Thanks for the replies, any of these will work.  I ended up reading line by line as Ravens Fan suggested.

 

Darrick 

Message Edited by DarrickZ on 10-27-2009 10:55 AM
Message Edited by DarrickZ on 10-27-2009 10:55 AM
0 Kudos
Message 7 of 7
(9,844 Views)