Combining several files into a single CSV
5,841
Solution 1
With paste
:
paste 1.txt 2.txt 3.txt
The output is:
1 Apple 55
2 Mango 100
3 Orange 30
Solution 2
To create a csv file, you can do it like this (setting the delimiter to a comma) :
paste -d"," 1.txt 2.txt 3.txt >> example.csv
Related videos on Youtube
Author by
Gautam
Updated on September 18, 2022Comments
-
Gautam over 1 year
Input files:
File:
1.txt
:1 2 3
File:
2.txt
:Apple Mango Orange
File:
3.txt
:55 100 30
Desired Output:
File:
example.csv
:column1 column2 column3 1 Apple 55 2 Mango 100 3 Orange 30
-
chaos over 8 yearsAlong with the fact that it's nearly the same answer as mine, it pastes the ouput together with a comma, not with tabs.
-
Yedric over 8 yearsQuestion specified CSV, which REQUIRES commas.
-
Yedric over 8 yearsQuestion specified CSV, which REQUIRES commas. Answer is missing commas.
-
chaos over 8 years@Yedric This is nowhere mentioned, the example output shows clearly tabs...
-
Yedric over 8 yearsthe title says CSV. I assumed that the output example was shown with separated columns for clarity.
-
Gautam over 8 yearsHi dudes, Thanks for your replies. Is it possible to copy these txt files as required previously in the 3 rd sheet in csv file? Look forward for your valuable reply.