I have multiple CSV files and I need to combine all of them into 1 CSV file.
So, for example:
1.csv has data like below:
| Roll no | Name |
|---|---|
| 1 | Abc |
| 2 | xyz |
2.csv has data like below:
| Name | Date | Score | Remarks |
|---|---|---|---|
| Mno | 20-12-2023 | 450 | |
| Pqr | 21-12-2023 | 480 |
and I want the combined CSV file for this data like below:
Master.csv
| Roll no | Name | Date | Score | Remarks |
|---|---|---|---|---|
| 1 | Abc | |||
| 2 | xyz | |||
| Mno | 20-12-2023 | 450 | ||
| Pqr | 21-12-2023 | 480 |
if a specific column is not present in a CSV file then leave it as empty.
How can I do this in C#?
You could read the two files as
csv2.GetRecords<dynamic>()and get the dynamic properties to create a newdynamiclist with a union of the two sets of headings.