Get Inspire insights from former attendees in our AMA discussion thread on Inspire Buzz. ACEs and other community members are on call all week to answer!

Alteryx Designer Desktop Discussions

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

Using directory to get Folder Names only and not subfolders or files

wonka1234
10 - Fireball

Hi,

 

How can I pull folder names from a directory? I do not want the subfolders or files names

I also want the folder names even if they do not contain a file.

 

Thanks.

15 REPLIES 15
BS_THE_ANALYST
14 - Magnetar

@wonka1234 I think I got it now! Just insert your link into the Text Input file (replace the current one). Press 'Run'. Click on the output anchor 1, all folders should be displayed even if they are empty! This doesn't contain the subdirectory folders though. Just all folders within the current folder. 

BS_THE_ANALYST_0-1673887884280.png

BS_THE_ANALYST_1-1673887971007.png

 

 

APIUserOpsGiri
7 - Meteor

Do you have a script to perform this? because I tried but seems the host can't connect this way when a directory is outlined. Can you attach an example workflow of this working?

FinnCharlton
13 - Pulsar

@BS_THE_ANALYST very nice

wonka1234
10 - Fireball

@BS_THE_ANALYST 

 

would you be able to share the python? I cannot view it in jupyter notebook.

binay2448
11 - Bolide

Have you checked my solution? You have to run as an App and provide path.

BS_THE_ANALYST
14 - Magnetar

@wonka1234 code is underneath the picture below. Hopefully it works for you. Just copy as paste it in the Jupter Notebook.

BS_THE_ANALYST_0-1673889489776.png

 

from ayx import Package
#Package.installPackages(['pandas','numpy'])
from ayx import Alteryx
import os
import numpy as np
import pandas as pd

 

var1 = Alteryx.read("#1")
a = var1.iloc[0,0]
link = a.replace("\\","/")
link
# # Get list of folders in file path
folder_list = os.listdir(link)

[folder for folder in folder_list if folder.find(".") == -1 ]

df = pd.DataFrame(data = [folder for folder in folder_list if folder.find(".") == -1 ], columns=["Folders"])
Alteryx.write(df, 1)

 

Labels