Advent of Code is now back for a limited time only! Complete as many challenges as you can to earn those badges you may have missed in December. Learn more about how to participate here!
Start Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Filter out file one step inside given folder path and not in other folders

saachitalwar
8 - Asteroid

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?

4 REPLIES 4
alexnajm
18 - Pollux
18 - Pollux

What is the logic to decide on one versus the other? Can you provide a concrete example?

Yoshiro_Fujimori
15 - Aurora
15 - Aurora

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.

saachitalwar
8 - Asteroid

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'

saachitalwar
8 - Asteroid

I used reg ex parse to get string after Production and it worked!
Thanks for your help

Labels
Top Solution Authors