Skip to content

Instantly share code, notes, and snippets.

@NotTheEconomist
Created January 27, 2015 22:33
Show Gist options
  • Save NotTheEconomist/2fc47c411aa5a71e0748 to your computer and use it in GitHub Desktop.
Save NotTheEconomist/2fc47c411aa5a71e0748 to your computer and use it in GitHub Desktop.
with open('new.txt') as f, open('orig.txt') as f2:
def zipper(f, f2):
for line in zip(f, f2):
yield line
next(f2) # skip every other f2 line
with open('out.txt', 'w') as out:
out.writelines(zipper(f,f2))
# then replace orig.txt with out.txt
# maybe os.remove('orig.txt'); os.rename('out.txt', 'orig.txt') ?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment