I am reading all the files inside a given directory - address\Production
I want to read a file that has the path - address\Production\01\file.xlsx
The issue is - inside the 01 folder there are multiple folders that have the same file name i.e. - address\Production\01\user1\file.xlsx and address\Production\01\user2\file.xlsx
I have filtered out files if they are present in 01 folder but need help with filtering out address\Production\01\file.xlsx from the other user files.
How can filter out the file that is in the 01 folder and not the other folders?
Solved! Go to Solution.
What is the logic to decide on one versus the other? Can you provide a concrete example?
Assuming that you want to filter the files at a specific depth (= 3) from the parent directory ("address\Production"),
you may just count the number of "\" in the path.
Input Data
Field1 |
address\Production\01\file.xlsx |
address\Production\01\user1\file.xlsx |
address\Production\01\user2\file.xlsx |
address\Production\02\user1\file.xlsx |
address\Production\02\user2\file.xlsx |
address\Production\03\file.xlsx |
address\Production\03\user3\file.xlsx |
Expression in Filter Tool
REGEX_CountMatches([Field1], "\\") = 3
Output Data
Field1 |
address\Production\01\file.xlsx |
address\Production\03\file.xlsx |
I hope this helps.
This is giving 0 for all values.
Also, the address is longer than address\Production... Is there a way to count number of '\' AFTER 'Production'
I used reg ex parse to get string after Production and it worked!
Thanks for your help