topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Saturday December 14, 2024, 6:34 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: merge two files to one  (Read 4801 times)

ljbirns

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 229
    • View Profile
    • Donate to Member
merge two files to one
« on: November 01, 2006, 09:05 AM »
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
  • ***
  • default avatar
  • Posts: 3,205
    • View Profile
    • Donate to Member
Re: merge two files to one
« Reply #1 on: November 01, 2006, 09:33 AM »
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/...ft/txtutil2.htm#sort

From RPSORT's help:
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
    • View Profile
    • Donate to Member
Re: merge two files to one
« Reply #2 on: November 01, 2006, 10:10 AM »
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,914
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: merge two files to one
« Reply #3 on: November 01, 2006, 09:30 PM »
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
    • View Profile
    • Donate to Member
Re: merge two files to one
« Reply #4 on: November 02, 2006, 08:30 AM »
Mouser

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