I came up with below script to do that. It takes the input as two file and print the output as merge of two files data per line.
import sys def merge_files(argv): f1 = open(argv[0], "r") f2 = open(argv[1], "r") lines1 = f1.readlines() lines2 = f2.readlines() count = 0 for line in lines1: line = line.rstrip() + lines2[count].rstrip() print line count = count + 1 if __name__ == "__main__": merge_files(sys.argv[1:]) |
Save the above code to file in python file. Now you just have to execute the on command line as "python <filename>.py file1 file2".
No comments:
Post a Comment