Read csv file with Random id in file name

I want to program a robot to read a csv file found in a folder. However ever time a new csv file is put into the folder there is a unique id in the name of the file. The name would always have the same format with a name followed by an “_” then the date, YYYYMMDD, then the unique number , e.g. Account_20200216_981237.

Would like to know how to read the csv file and store the data into a data table without having to know what the unique number at the end is.

So if I understood correctly, you would like to read a CSV file’s content but the CSV filename is unknown to you.

What I would do is loop the directory and pick the file(s) you would like to have read by the robot. Here’s the code that you are able to use in the Invoke Code activity setting the activity’s language to “CSharp”:

string[] Files = Directory.GetFiles(@"C:\MyDir", "*.csv");
foreach (string Filename in Files) {
	Console.WriteLine(Filename);
}

You could then further think about the logics as to how to handle processed files.

Read the following on how to read a CSV file and store its data into a DataTable:

Good luck.

@OpalSnow i have an idea of what to do using either the RegEx build or a contains method. Thanks a lot.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.