Reputation: 331
I have multiple flat files(.csv) as my source in a folder.Each file has varying number of columns which may or may not intersect with other files. However, all columns in any source file are always present in my destination table that contains the super set of all these columns.
My requirement is to loop through each of these files and dynamically map columns that are available in that file to the destination table(header names of csv file match column names in table).
Structure of File 1:
id, name, age, email
Structure of File 2:
id, name, age, address, country
Structure of File 3:
id, name, age, address
Structure of Destination Table:
id, name, age, address, country, email
I want to populate the table for all columns with data for what is available and NULL
for what's not for every record. How can I achieve this using SSIS?
Upvotes: 2
Views: 626
Reputation: 37313
you can do this by adding one Flat File Connection Manager
add only one column with Data type DT_WSTR
and a length of 4000
(assuming it's name is Column0
)
dataflow task
add a Script Component
after the Flat File Source
Column0
as Input Column and Add 6 Output Columns (id, name, age, address, country, email)
Input0_ProcessInputRow
method split this column and assign values to output column. (you can write the logic you want) you can read answers at the following question to get an example: Reading CSV file some missing columnsUpvotes: 0
Reputation: 4610
The Flat File Source
does not support dynamic file format, you have to use multiple sources to load these files.
Upvotes: -1