Superimpose.py

From XPUB & Lens-Based wiki
Revision as of 10:51, 23 November 2013 by Michael Murtaugh (talk | contribs) (Created page with "== Code == <source lang="python"> import itertools import sys for x, y in zip(open(sys.argv[1]), open(sys.argv[2])): for xc, yc in itertools.izip_longest(x.rstrip('\r\n')...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Code

import itertools
import sys

for x, y in zip(open(sys.argv[1]), open(sys.argv[2])):
    for xc, yc in itertools.izip_longest(x.rstrip('\r\n'), y.rstrip('\r\n'), fillvalue=' '):
        if yc == ' ':
            sys.stdout.write(xc);
        else:
            sys.stdout.write(yc);
    sys.stdout.write('\n')

Source: Alexandre Leray