Skip to content

Instantly share code, notes, and snippets.

@chrismaddalena
Created April 11, 2016 19:22
Show Gist options
  • Save chrismaddalena/3477828c7f37b93f1377c34351f57085 to your computer and use it in GitHub Desktop.
Save chrismaddalena/3477828c7f37b93f1377c34351f57085 to your computer and use it in GitHub Desktop.
Take two lists and combines them into one with alternating lines from each, like a zipper
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import os
fileOne = sys.argv[1]
fileTwo = sys.argv[2]
with open(fileOne, 'r') as one, open(fileTwo, 'r') as two, open('combined.txt', 'w') as output:
for line in one:
output.write(line.rstrip() + '\n')
output.write(two.readline().strip() + '\n')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment