Text File Update

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



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.


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

Search DelphiForFun.org only



File Update is does text match-merge processing of a file of Update transactions against a Master file. 

Each DFF newsletter that goes out results in 50 or so undeliverable.   There is no automatic mechanism to remove these invalid email addresses from the subscriber list, so I spend an hour or two manually updating the list each time.    I recently decided to automate this process.   The final product will scan reject emails and extract the addresses to delete, but in Phase 1, this program,  I drag the email addresses to a text file which the program sorts and passes against the subscriber list to delete matching records. 

I've generalized the program to optionally add records which do not exist.

Note that the match "key" is the entire record which probably restricts the [program's usage to simple list of names or objects.  

There are a surprising number of decisions to make when matching two files.  Here are the options that  ended up as radio button boxes in the program:

  • Action to take when update record matches master record
    • Delete master record (default)
    • Ignore       
  • Action to take when an update record does not match aster record
    • Add transaction to a master record
    • Ignore the transaction  (default)
  • If duplicate records are found in Master file:
    • Leave them in Master
    • Delete duplicates (default)
  • If duplicate update transactions are found: (If previous option is "Delete Duplicates", then this box will be hidden and duplicate update transactions  will be ignored.) 
    • Process the transaction according to option below
    • Ignore duplicate update transactions (default)
  • How to match: (If previous option is set to "Ignore duplicate updates", this box will be hidden and each transaction will delete all matching master records.)  
    • Delete at most one master record 
    • One update transaction will delete all matching master records (default)

Additional options control:

  • Whether upper and lower case is ignored when comparing (i.e. albert=Albert).
  • An option allows leading and trailing blanks to be deleted before comparison.  

Note for programmers:

There's a new experimental TSyncMemo class implemented here to synchronize the three TMemos used to display Master record, Update transactions, and Action taken.   An arbitrary number of TMemos can be associated with a TSyncMemo.   Only vertical scrolling is synchronized.   It's not perfect, the "slave" TMemos can be scrolled independently even though no vertical scroll bars are specified, but it was quite simple to implement and works well enough for now.  An enhanced version may show in Delphi Techniques one of these days

Files are loaded into TStringlists which are sorted using CustomSort to handle user  case sensitivity option.

Download Programs

The program has not been extensively tested and is presented "as is" for your testing or modification.   Always save output to a new file until you have verified its correctness.  

Download source

Download executable


Created 11 April  2005  

Modified 18 Feb 2016



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