This may be a simple/repeat question, but I could find/figure out yet how to do it.
I have two csv files:
info.csv:
"Last Name", First Name, ID, phone, adress, age X [Total age: 100] |009076
abc, xyz, 1234, 982-128-0000, pqt,
bcd, uvw, 3124, 813-222-1111, tre,
poi, ccc, 9087, 123-45607890, weq,
and then
age.csv:
student_id,age_1
3124,20
9087,21
1234,45
I want to compare the two csv files, based on the columns "id
" from info.csv and "student_id
" from age.csv and take the corresponding "age_1
" data and put it into the "age
" column in info.csv.
So the final output should be:
info.csv:
"Last Name", First Name, ID, phone, adress, age X [Total age: 100] |009076
abc, xyz, 1234, 982-128-0000, pqt,45
bcd, uvw, 3124, 813-222-1111, tre,20
poi, ccc, 9087, 123-45607890, weq,21
I am able to simply join the tables based on the keys into a new.csv, but can't put the data in the columns titles "age
". I used "csvkit
" to do that.
Here is what I used:
csvjoin -c 3,1 info.csv age.csv > new.csv