Last active
January 12, 2021 15:25
-
-
Save RodrigoDornelles/2835550e52e6fc7513e9356e861d8991 to your computer and use it in GitHub Desktop.
concatenate two files line by line using a simple python script.
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
import sys, itertools | |
try: | |
file1, file2 = open(sys.argv[1], 'r').readlines(), open(sys.argv[2], 'r').readlines() | |
[sys.stdout.write(l1.replace('\n', '') + l2.replace('\n', '')) for (l1,l2) in itertools.zip_longest(file1, file2, fillvalue='')] | |
except: | |
sys.stderr.write('[!] Error: require two valid files!') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment