Darshan Hiranandani : How can I programmatically select the first CSV file from a folder regardless of its name?

Hi Team,

I’m Darshan Hiranandani, working on a task where I need to programmatically select the first CSV file from a folder, without knowing the file’s name in advance.

Could you please share your suggestions or methods for achieving this? Any advice on libraries or code snippets that could help with this would be greatly appreciated.

Thanks in advance for your input!

Best regards,
Darshan Hiranandani

Hi @darshanhiranandani23.
Do you mean: first file ordered by date?
If so, read the directory and insert a REGEX filter .*/.csv and will return of all files with this extension. Then sort by date descending order.
FIrst file will be the newest.

If you sort ascending, use identify last row and filter out all those that do not comply as last row.

Hope this helps.