I have multiple CSV files and I would like to take them all, and write them into one single file. It should be possible to configure and map columns from input files to columns of output files. And if output column is not present in the input file, default it to empty.
Here is an example:
File one:
'Name', 'Surname', 'Address'
'John', 'Doe', 'example st 123'
File two:
'Surname', 'Age', 'City'
'Doe', '50', 'Riga'
Output File:
'Name', 'Surname', 'Address', 'Age', 'City'
'John', 'Doe','example st 123', ' ', ' '
' ', 'Doe', ' ', '50', 'Riga'
The input data would come in as an array. Reading and writing part I would manage, but the mapping part I have no idea how to do. I'm looking for some inbuilt or custom functions that could help with this or give me an idea on how to approach this at all.
Any ideas will be appreciated.