Script : Merging two file lines using python

I had two file containing some information per line. I wanted to merge the line from file one and line form file two as a single line and print on the console. 
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__":

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".


Popular posts from this blog

How to boot Samsung Galaxy SL( GT-I9003) in recovery mode

How to flash CWM Recovery to Samsung Galaxy SL( GT-I9003) using Odin

How to Factory Reset or Hard Reset Samsung Galaxy SII ( GT-i9100)