On Sat, May 15, 2010 at 3:22 AM, mannu jha <mannu_0...@rediffmail.com> wrote: > Hi, > > I have two different file > > file1: > > a1 a2 > a3 a4 > a5 a6 > a7 a8 > > file2: > > b1 b2 > b3 b4 > b5 b6 > b7 b8 > > and I want to join them so the output should look like this: > > a1 a2 b1 b2 > a3 a4 b3 b4 > a5 a6 b5 b6 > a7 a8 b7 b8 > > how to do that?
This is completely untested, but this "should" (tm) work: from itertools import chain input1 = open("input1.txt", "r").readlines() input2 = open("input2.txt", "r").readlines() open("output.txt", "w").write("".join(chain(input1, input2))) cheers James -- http://mail.python.org/mailman/listinfo/python-list