0

I need to combine set of csv files into one, but I need to keep the variable from the file name.

Example is below

file name: Paris_correlations.csv data as below:

ID A B C
x  2 4 6
y  5 7 9

file name: Madrid_correlations.csv data as below:

ID A B C
x  4 6 2
y  1 8 5

and I need to combine this into one file - combined.csv

ID city A B C
x  Paris 2 4 6
y  Paris 5 7 9
x  Madrid 4 6 2
y  Madrid 1 8 5 

And I have more than 1000 files like that (there is constant element in names of the files - ***_correlations.csv).

How can I combine this?

anba
  • 543
  • 1
  • 4
  • 7

0 Answers0