in reply to Re: Merging larges files by columns
in thread Merging larges files by columns
The idea is to have both file1 and file2 in an order such that it is just a stepwise ladder walk. Our mythical ladder walker has one foot on ladder1 and one foot on ladder2 and if a foot moves, it moves upward.
This takes a long time:
A step-wise walker algorithm is a merge of 2 sorted files and is much faster because all that is needed is to decide who goes next, like 2 cars at a stop sign.foreach line in file1... { loop through lines in file2... { ...many comparisons... decide which one is next } }
foreach line in file1... { # insert file2 line(s) that should go before the # current line from file1 while {the current line in file2 is "next" in total order} { output that line from file2; move to next line in file2 } output the file1 line } output rest of file2 lines (if any)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Merging larges files by columns
by aaron_baugher (Curate) on Sep 17, 2011 at 11:53 UTC | |
by Marshall (Canon) on Sep 19, 2011 at 00:59 UTC |