0

I have two large csv files that share the same first column and first row (header) as follow: etc means more values with same pattern.

file1.csv

names,text1,text2,text3,etc
A,1,4,3 ...
B,5,2,8 ...
C,3,7,4 ...
D,9,1,3 ...
etc

file2.csv

names,text1,text2,text3,etc
A,7,2,9 ...
B,3,0,6 ...
C,8,7,2 ...
D,1,5,6 ...
etc

I would like a code/script to combine columns (with matching headers or column #)from file1.csv and file2.csv in addition to the first column from file1.csv and output them in new files named based on the header.

So it would give the following output files and so on:

text1.csv

names,text1,text1
A,1,7
B,5,3
C,3,8
D,9,1
etc

text2.csv

names,text2,text2
A,4,2
B,2,0
C,7,7
D,1,5
etc

text3.csv

names,text3,text3
A,3,9
B,8,6
C,4,2
D,3,6
etc
tenten
  • 11
  • 2
  • Does this answer your question? [How to outer-join two CSV files, using shell script?](https://stackoverflow.com/questions/71053039/how-to-outer-join-two-csv-files-using-shell-script) – Zach Young Mar 31 '22 at 02:42

0 Answers0