Created
April 3, 2014 19:28
-
-
Save rtxanson/9961131 to your computer and use it in GitHub Desktop.
I'm sure there's a bash oneliner for this, but I had no clue how to Google for it. ;)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" ./leftmerge.py filename filename2 [delimeter] | |
Example input: | |
filename contains | |
talo | |
sana | |
kirja | |
filename2 contains | |
+N+Sg+Nom | |
+N+Pl+Nom | |
+N+Sg+Par | |
Output: | |
A+X | |
A+Y | |
A+Z | |
B+X | |
B+Y | |
B+Z | |
C+X | |
C+Y | |
C+Z | |
""" | |
import sys | |
def main(): | |
left, right = sys.argv[1], sys.argv[2] | |
try: | |
d = sys.argv[3] | |
except: | |
d = '' | |
with open(right, 'r') as F: | |
lines = [a.strip() for a in F.readlines()] | |
with open(left, 'r') as F: | |
for l in F: | |
for r in lines: | |
print >> sys.stdout, l.strip() + d + r | |
if __name__ == "__main__": | |
sys.exit(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment