combine multiple text files with different number of columns separated by tab, into one merged text file in python

Issue

This Content is from Stack Overflow. Question asked by u.b

What is the simplest way to combine multiple txt files into one merged file, where each file contains different number of columns and I need to get one merged file with all the columns as follows:

file1.txt
1.04
2.26
3.87

file2.txt
5.44 4.65 9.86
8.67 5.89 7.45
8.41 6.54 6.21

file3.txt
6.98 6.52
4.45 8.74
0.58 4.12

merged.txt
1.04 5.44 4.65 9.86 6.98 6.52
2.26 8.67 5.89 7.45 4.45 8.74
3.87 8.41 6.54 6.21 0.58 4.12

I saw here answer to the case of one columns in each file.

how can i do this for multiple columns?



Solution

This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?