I have a csv file called scenario1.csv in which the second column has column names like "0-4 years high risk", "65+ years first responder" etc. There are 20 such values. The 21st row, 2nd column has the same entry as in the 1st row of the 2nd column. I would like to rename these values to p1-p20 respectively. So the 21st row would have the p1 tag with it. Everything without quotes. I have a 150 such files, named scenario1.csv, scenario2.csv ... How do I do this? Below is an example for a shorter file:
t, group, 1, 3, 5
0, 0-4 years low risk, 0, 0, 0
0, 0-4 years high risk, 0, 0, 1
....., ....
0, 0-4 years low risk, 0, 0, 0
Expected output for each file:
t, group, 1, 3, 5
0, p1, 0, 0, 0
0, p2, 0, 0, 0
....., ....
0, p1, 0, 0, 0
Here's the dictionary I need:
0-4 years first responder p1
0-4 years high risk p2
.......
65+ years low risk p19
65+ years pregnant women p20