Loading ...
Sorry, an error occurred while loading the content.

22017Merging two files

Expand Messages
  • John Shotsky
    Aug 25, 2011
    • 0 Attachment
      I'm looking for a standard way to add the contents of a file (file2) to the ends of the matching lines of another file.

      Both files have the same number of lines, and I can begin each line with a number, such as 1., 2., if needed. Or they
      can both start with a unique text name. There will never be duplicate lines within either file.

      I have been doing this by copying the contents of file2 to the bottom of file1, then using a replace statement to
      replace the first line with itself plus the desired contents of the lower matching line, which is consumed in the
      process. When no more matches are found, it is done. There is no row counting, etc, just an 'IfError Next Else Skip_-1
      to keep repeating the process until all the lower lines are consumed.

      Is there a more direct way to do this? I'd like to create a general purpose clip that would add any file2 to any file1
      without first copying file2 into file1, then processing them. There will always be a key at the beginning of these lines
      in both files, but otherwise the content of each line will be different. I suspect there is a way to do this with an
      array, but I don't know how to construct that.

      One example of this would be adding page numbers found only in file2 to each matching line in file1.

    • Show all 10 messages in this topic