Clear Blank lines

[Home]   [Puzzles & Projects]    [Delphi Techniques]   [Math topics]   [Library]   [Utilities]

 

 

Search

Search WWW

Search DelphiForFun.org

As of October, 2016, Embarcadero is offering a free release of Delphi (Delphi 10.1 Berlin Starter Edition ).     There are a few restrictions, but it is a welcome step toward making more programmers aware of the joys of Delphi.  They do say "Offer may be withdrawn at any time", so don't delay if you want to check it out.  Please use the feedback link to let me know if the link stops working.

 

Support DFF - Shop

 If you shop at Amazon anyway,  consider using this link. 

     

We receive a few cents from each purchase.  Thanks

 


Support DFF - Donate

 If you benefit from the website,  in terms of knowledge, entertainment value, or something otherwise useful, consider making a donation via PayPal  to help defray the costs.  (No PayPal account necessary to donate via credit card.)  Transaction is secure.

Mensa® Daily Puzzlers

For over 15 years Mensa Page-A-Day calendars have provided several puzzles a year for my programming pleasure.  Coding "solvers" is most fun, but many programs also allow user solving, convenient for "fill in the blanks" type.  Below are Amazon  links to the two most recent years.

Mensa® 365 Puzzlers  Calendar 2017

Mensa® 365 Puzzlers Calendar 2018

(Hint: If you can wait, current year calendars are usually on sale in January.)

Contact

Feedback:  Send an e-mail with your comments about this program (or anything else).

Search DelphiForFun.org only

 

 

 

Here's a "quick and dirty" little program to remove blank lines from a specified input text file and write non-blank lines to a specified output file.

The program was motivated when our Booksearch Index page somehow had 35,0000 lines containing only   10 blank characters per line somehow got inserted among 136 valid htm code lines. This expanded the HTML file from 12 Kbytes to 360KBytes and hung FrontPage, my web editor program.

After a 20 minute effort at manually deleting blanks, the job was less than 10%  complete with no assurance that I hadn't accidentally deleted valid lines,  so the manual approach was abandoned.

This program has 25 lines of my code and took about 15 minutes to code and run to complete the job.  Computers rule!  (Sometimes J.)

Addendum August 13, 2006:  A viewer with hundreds of files to fix, wrote asking for a version which would allow multiple files to be selected for processing in a single run.   Version 2, posted today, provides that ability.  Files are selected by the standard multi-select technique;  use Click and Shift-click to select a range of files, use Ctrl-click to select or deselect individual files.  Options are provided to backup files before processing or to provide a new name for each file.

October 30 2011: Here is a command line version of the program which will operate from a command line or  from a Windows batch file.  Either one is enough trouble to set up to make one appreciate the GUI features of current Delphi and Windows versions.  Nevertheless, batch files can be an easy way to repetitively run a program without user intervention.  That's the case for a user who requested this batch version of ClearBlankLines.   Parameters allow masked searches for files to be processed including ability to search subdirectories, and to make backups of files which are changed.  Since most people, will probably not be interested in this version, I'll refer those who are to the Batch version download below.  It contains a "Readme" file outlining program usage and also a sample ".bat" batch file with a couple of  text files for testing.  It runs OK here, but write if you find bugs or have questions, drop me an email and I'll try to help..

May 11, 2012:  Version 3 of the user interactive version and Version 2  of the command line version were posted today with the added option of trimming leading blanks from lines which contain text in addition to removing entirely blank lines. .    

June 11, 2012:  Last month's posting triggered a number of enhancement requests from users.  Version 3.1 posted today adds these features:

bulletTrailing blanks as well as leading blanks can now be removed from non-blank lines
bulletLeading  "Tab" characters, previously  treated a spaces and deleted with the "leading blanks" option, may now be optionally  retained or deleted when leading or trailing blanks are removed.
bulletA "character select" option allows lines with a specified character to be removed or to be the only lines retained in the output.  This was requested by a user needing to extract email addresses from text files.  Retaining lines with "@" characters will ease the process.
bulletA new "case" option allows  text to be converted to upper or lower case. 

Note: The command mode version, now has 12  instead of the previous 3 parameters.  Basic testing of the new features was completed but the chance of unintended interactions among the hundreds of possible  parameter combinations has increased.  The user  remains solely responsible for results, so testing and retaining backups before any mass conversion is strongly recommended!    

November 8, 2012:  I found another reason to modify Clear Blanks recently which led to posting Version 4 today.  I, along with many others, still use Delphi 7 as my first choice compiler.  One of the minor irritations has been that their final Help file update included Kylix (a Delphi 7 Linux version) help items in the D7Ref.toc (table of contents) file. This typically added extra time and an extra click to look up a Windows version VCL control.  But every Kylix help entry in the table of contents contains the string "[CLX]".  It was simple to  modify the "character select" option from the June update to find embedded strings rather than single characters to select lines to delete or keep.  Presto-change-o, my Delphi help file no longer knows that Kylix ever existed!   For flexibility, I also added a "Match case" check box to control whether the string searches are case sensitive.   

December 22, 2012:  Version 4.1 addresses a couple of small issues with both the Windows and the Command line versions of Clear Blank Lines.
bulletWhen removing blank lines, previous versions required the "Treat Tabs as spaces" option be set.  Version 4.1 honors the Tabs option, deleting only truly blank lines if  the option is not set but treating tabs as spaces when the option is set.   
bulletAll deleted lines were previously  written to a " Deleted"  file just in case, even when only blank lines were being removed.  Now only runs which have deleted non-blank lines create the file,   

Download source
Download executable
Download source and executable for the Batch Command line version

Created: September 19, 2005

Modified: May 11, 2018

  [Feedback]   [Newsletters (subscribe/view)] [About me]
Copyright © 2000-2018, Gary Darby    All rights reserved.