DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Author Topic: merge two files to one  (Read 6,262 times)

ljbirns

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 229
merge two files to one
« on: November 01, 2006, 03:05 PM »
I have two txt files. One is year 2005 customers and sales to date. The other is 2006 customers and sales to date. I would like to create one file  so that I can easily see a sales
comparison one file. The file looks like this for each account,

ACCOUNT:00044  XXXXX  YYYYY XXXXX  LOS ANGELES    CA,
ACCOUNT:00044  TOTAL $:        91.75  INVOICD:    91.75  ,
ACCOUNT:00044  TOTAL UNITS:        4  INVOICD:        4 

What software could I use to do this ?  ( XP Pro  SP2 )

And no the DOS propriatery software program we use for invoiceing etc can't do this.

Thanks
Lew

rjbull

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 3,217
Re: merge two files to one
« Reply #1 on: November 01, 2006, 03:33 PM »
You mentioned DOS, so presumably you are happy with command lines.  If I understand you correctly, and the file format is exactly as described, you could try concatenating your files, e.g.

copy file1.txt+file2.txt bigfile.txt

(or use a "cat" program) and sort the result with any sort program.  Or, in one pass and very fast, try RPSORT, available from DOS legacy sites e.g. the Free Software for DOS Web site.  Their sort utilities page is http://home.att.net/~short.stop/freesoft/txtutil2.htm#sort

From RPSORT's help:
Code
Usage: RPSORT [/Q] [/Eerrfile] [/]? [inputfile[+inputfile]] [outputfile] [/A]
          [/B] [/C] [/D] [/Fnnnn] [/N] [/P] [/R] [/td][/tr][/table] [/Z] [sort key defin...]

Sort key defin syntax:  /+ [col] [:len] [A] [C] [F] [I] [M] [P] [R] [T] [U]
-------------------------------------------------------------------------------
Parameters may be entered in any order except as noted below.

RPSORT may be run as a filter using redirection.

  For example:    RPSORT   <ipfile   >opfile
           or:    DIR | RPSORT | MORE

Input and output may be specified directly.  Input is one or more 
filespecs separated by plus signs.  Output must be a single file.  
Input filespec(s) must precede output filespec.  Filespecs may 
include a path.  Wildcard characters are allowed.  Input files are 
sorted together into the single output file.

  For example:    RPSORT ipfile*.txt+c:\mydir\ip??file.txt   opfile

By default, RPSORT assumes the input is a text file and that the 
entire line is the sort key.  The sort is case insensitive (lower 
equals upper case) and just like the DOS SORT it equates foreign 
letters, punctuation, and currency symbols to their English 
equivalents.  The following screens describe other options.

ljbirns

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 229
Re: merge two files to one
« Reply #2 on: November 01, 2006, 04:10 PM »
rjbull

Thanks.  That is a good idea. I will try that.  I also found two Window programs that put the two files side by side >  Beyond Compare and KDiff ( Sourceforge )

So my problem is solved.

Thanks
Lew

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,931
    • Gathering Badge
    • Plugin Coding Medal
    • Participated in NANY Challenge Seventeen Times
    • Cody Award
    • Coding Snacks
    • Volunteers/Staff
Re: merge two files to one
« Reply #3 on: November 02, 2006, 03:30 AM »
i am a HUGE fan of Beyond Compare;
for open source you might also try WinMerge (http://winmerge.org/)

ljbirns

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 229
Re: merge two files to one
« Reply #4 on: November 02, 2006, 02:30 PM »
Mouser

I like it too.  Is there a way that I can manipulate each window individually ?
Lew

Original address: https://www.donationcoder.com/forum/index.php?topic=6000.0