June 25, 2023 at 3:49 am
There are several text files that are saved in a local driver. The file names are:
Each file has only one record. The record includes fields of CustomerID, FirstName, LastName, and SubmittedDate, see below.
I would like to add CustomerID, LastName and CurrentDate to the file name. The format for file name is CustomID_LastName_FileName_CurrentDate.
Thanks in advance.
June 25, 2023 at 8:22 am
What technique are you using to create the files? A data flow within a loop, perhaps?
What method are you currently using to name the files? Script task? Dynamic variable? Something else?
June 26, 2023 at 1:43 am
I use a Data Flow Task within For Loop Container to split rows into files and save to a local drive. The file names are from a variable 'Counter' that is used in Flat File Connection Manager expression.
Thank you!
June 26, 2023 at 12:11 pm
This is an interesting one. This is what I would try, I think:
First, change the way that the file-naming works. I'd use a static file name (somefile.txt, or whatever), and add a task to rename the file after the dataflow task completes, but inside the For Loop container.
The rename would be from somefile.txt to a variable User::filename.
User::filename would be set inside the dataflow task. Add a Script Component transformation between source and target and add User::filename to the read/write variables collection. Add CustomerId, LastName to the Input Columns collection.
A simple bit of C# will allow you to set the value of User::filename as required.
If you have full control over the filename format, I'd suggest you consider using YYYYMMDD_CustId_Surname.txt instead, where YYYYMMDD is 'today'. If you do this and ever find you have files in a folder created over a number of days, you'll easily be able to sort the filenames by creation date in File Explorer.
June 26, 2023 at 10:56 pm
Many thanks! How to use a static file name because the variable Counter is dynamic?
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply