remove blank lines from text file
Posted: Wed Apr 05, 2017 2:55 pm
I have a project where I am:
saving the message body of an email to a text file.
Reading the flat text file at line 7, skipping empty rows (this strips out some unneeded header information)
performing a search and replace to remove a line of text at the bottom of the flat file with system.emptyString
The result is the lines of data I want and two blank lines. When I try to read this as a fixed width file to insert I am getting an invalid record error. Apparently this is due to the blank lines. If I manually remove the text at the bottom of the text file there are no errors.
What's the best way to delete blank lines from a flat or fixed width file?
saving the message body of an email to a text file.
Reading the flat text file at line 7, skipping empty rows (this strips out some unneeded header information)
performing a search and replace to remove a line of text at the bottom of the flat file with system.emptyString
The result is the lines of data I want and two blank lines. When I try to read this as a fixed width file to insert I am getting an invalid record error. Apparently this is due to the blank lines. If I manually remove the text at the bottom of the text file there are no errors.
What's the best way to delete blank lines from a flat or fixed width file?