I have a folder with 12 files that look like this
abcd@202201.xlsx
abcd@202202.xlsx
abcd@202203.xlsx
abcd@202204.xlsx
abcd@202205.xlsx
abcd@202206.xlsx
abcd@202207.xlsx
abcd@202208.xlsx
abcd@202209.xlsx
abcd@2022010.xlsx
abcd@2022011.xlsx
abcd@2022012.xlsx
Also, I’ve already got a data table(dt_names) that looks like the following
Names
Aaron
Andrew
Justin
How do I extract the date of the 12 files and write it into each column of my existing data table, so it would look like this?
Names 202201 202202 202203 … 202212
Aaron
Andrew
Justin
Use Assign activity & get the file names in an array:
fileNamesArray = Directory.GetFiles(“Folder Path in which 12 files are located”)
Iterate through each array element by using ForEach activity.
Inside the loop, use the regex to extract the numeric values & store it in a string variable:
currentMatch = System.Text.RegularExpressions.Regex.Matches(inputString, pattern)
Inside the loop, after the above action, use Add Data Column to add the columns. In each iteration, the column will be added.