22026RE: [Clip] Merging two files
- Aug 27, 2011Thank you, Flo and Art! I'm on another task right now, but will get back to this in a day or two.
From: email@example.com [mailto:firstname.lastname@example.org] On Behalf Of flo.gehrke
Sent: Saturday, August 27, 2011 13:56
Subject: Re: [Clip] Merging two files
--- In email@example.com <mailto:ntb-clips%40yahoogroups.com> , "John Shotsky" <jshotsky@...> wrote:
> I want a general purpose method, because there are different
> cases of what needs to be done. In some cases, each line in
> file1 and file2 start with the same words, which facilitates
> the match. In other cases, there will be two files with
> simply the same number of lines, but I want the same process to
> occur � the contents of file2 appear on the ends of each
> File1 line, but without matching words in file2.
If the two files should be combined 'line by line' like...
file1 line #1 + file2 line #1
file1 line #2 + file2 line #2
I think this is perfectly achieved with Art's idea (message #22020) according with your sample.
Completing Art's proposal and providing that both File1 and File2 contain the same amount of lines you could try...
^!If ^%i% > ^%Left0% Out
^!AppendtoFile ^$GetDocumentPath$NewFile.TXT ^%Left^%i%% ^%Right^%i%%^%NL%
; In case you want to replace the original File1...
^!RenameFile ^$GetDocumentPath$NewFile.TXT ^$GetDocumentPath$File1.txt
If you want to see the result in a new document before saving it to the disk you might prefer the following clip. It
also avoids empty lines...
; Strip empty records from end of array (by courtesy of Eb)
^!If "^%Left^%Left0%%" <> "^%Empty%" Skip Else ^!Dec %Left0%
^!If ^%i% > ^%Left0% End
^!InsertText ^%Left^%i%% ^%Right^%i%%^%NL%
If the result is correct save it as File1.TXT replacing the original file.
[Non-text portions of this message have been removed]
- << Previous post in topic Next post in topic >>