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

**URL:** <https://community.automationedge.com/t/darshan-hiranandani-how-can-i-programmatically-select-the-first-csv-file-from-a-folder-regardless-of-its-name/12994>\
**Category:** Process Studio\
**Tags:** rpa\
**Created:** [August 13, 2024, 7:07am UTC](https://community.automationedge.com/t/darshan-hiranandani-how-can-i-programmatically-select-the-first-csv-file-from-a-folder-regardless-of-its-name/12994 "2024-08-13T07:07:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![darshanhiranandani23](https://avatars.discourse-cdn.com/v4/letter/d/4491bb/32.png) [@darshanhiranandani23](https://community.automationedge.com/u/darshanhiranandani23)\
**Post date:** [August 13, 2024, 7:07am UTC](https://community.automationedge.com/t/darshan-hiranandani-how-can-i-programmatically-select-the-first-csv-file-from-a-folder-regardless-of-its-name/12994/1 "2024-08-13T07:07:25Z")

</div>

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**

---

<div class="post-metadata">

**Author:** ![wllmdjngh](https://yyz1.discourse-cdn.com/flex027/user_avatar/community.automationedge.com/wllmdjngh/32/952_2.png) [@wllmdjngh](https://community.automationedge.com/u/wllmdjngh)\
**Post date:** [August 13, 2024, 1:21pm UTC](https://community.automationedge.com/t/darshan-hiranandani-how-can-i-programmatically-select-the-first-csv-file-from-a-folder-regardless-of-its-name/12994/2 "2024-08-13T13:21:25Z")

</div>

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.
