Skip to content

Instantly share code, notes, and snippets.

@rtxanson
Created April 3, 2014 19:28
Show Gist options
  • Save rtxanson/9961131 to your computer and use it in GitHub Desktop.
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. ;)
""" ./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