I am joining data from 2 different sources and I need to use the 2nd source to update the first. The first data source is some database data and the second data source is a csv with items that need to be updated within the database data (these updates could be new rows, changes in value to existing rows, etc.). The first source has 50+ columns and the second source will have varying amounts of columns.
I need to join/merge these two data sources and overwrite values from the database with the values in the csv when the column names are the same and add in any data that is missing
Ex:
DB
| key | col1 | col2 | col3 | col4 | col5 |
| 1 | 0 | 300 | string1 | null | null |
| 2 | 1 | 250 | string2 | null | null |
| 3 | 1 | 200 | string3 | null | null |
| 4 | 0 | 225 | string4 | null | null |
csv
| key | col2 | col3 | new col |
| 2 | 75 | string two | b |
| 3 | 25 | string three | c |
| 5 | 50 | string five | e |
output
| key | col1 | col2 | col3 | col4 | col5 | new col |
| 1 | 0 | 300 | string1 | null | null | null |
| 2 | 1 | 75 | string two | null | null | b |
| 3 | 1 | 25 | string three | null | null | c |
| 4 | 0 | 225 | string4 | null | null | null |
| 5 | null | 50 | string five | null | null | e |
I need for this to be pretty dynamic since the columns that are updated will vary and also because of the amount of columns in the db. If anyone has any thoughts on this or can provide any insight on how I could do this it would be greatly appreciated.