Reputation: 67
I have two files that are named like this: CustomerReport(08022021-08032021) ComparingReport(08022021-08032021) I need to load the CustomerReport to a table and the ComparingReport to another table. I tried for each loop container but I cant think of how the expression will be to pickup the file. Im thinking of something like Customer*.csv where the * acts like a wild card but that didnt work. What can I do in this case?
Upvotes: 1
Views: 1398
Reputation: 1288
Here key of the answer is to use Foreach Loop
and Conditional Split
.
Don't pay attention on errors, because I don't have your CSV files and tables in DB!
FileName
- string data typeforeach loop
and set like on screenshotCollection Tab:
Variable Mappings Tab:
Add Data Flow Task
into Foreach Loop
container
Drag elements from toolbox like on a image
Flat File Source
connect to one of your CSV file using Flat File Connection Manager
and on connection manager, in properties > expressions, set for ConnectionString
a variable FileName
Set Conditional Split
like on a image
Expression for Customer
is:
LEFT(
SUBSTRING(@[User::FileName],FINDSTRING((@[User::FileName]),"Customer",1),100),
FINDSTRING(SUBSTRING(@[User::FileName],FINDSTRING((@[User::FileName]),"Customer",1),100),"Report",1) - 1
) == "Customer"
Conditional Split
to OLE DB Destination's
NOTE: I can't run package as I said on top of this answer, Pay attention to Conditional Split
, but this is the way how you need to find if part of a string is into whole string.
Upvotes: 1