0

suppose I have text files a , b ,c

file a

1

2

3

file b

a

b

c

file c

d

e

f

I want to write an output file like:

1 a d

2 b e

3 c f

Anyway to write it in python or any commands in Linux?

2 Answers 2

3

In the command line:

$ paste a b c
1   a   x
2   b   y
3   c   z
Sign up to request clarification or add additional context in comments.

Comments

2

You can use zip for this:

with open("filea") as f1, open("fileb") as f2, open("filec") as f3:
    for a, b, c in zip(f1, f2, f3):
        print " ".join(map(str.rstrip, (a, b, c)))

1 Comment

Actually there are a thousand of lines, not just a,b,c.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.