我使用下面在Alteryx工作流中运行的python代码。我想添加一个列,以便它可以列出这些文件夹中的所有文件。你知道我如何将这些信息添加到下面的代码中吗
from ayx import Alteryx
import pandas as pd
import numpy as np
import os
import glob
# FILE SERVER
fileDirectoryPath = Alteryx.read(r'#1')
filePathInput = fileDirectoryPath.iloc[0,0]
absPathList = glob.glob(filePathInput + '\\*\\*\\*\\*')
absPathListFiltered = [x for x in absPathList]
fullPathList = [f for f in absPathListFiltered if '.txt' not in f and '.bat' not in f]
folderList = [f.split('\\')[-1] for f in absPathListFiltered if '.txt' not in f and '.bat' not in f
and '.ini' not in f and '.gdoc' not in f]
parentList = [f.split('\\')[-2] for f in absPathListFiltered if '.txt' not in f and '.bat' not in f
and '.ini' not in f and '.gdoc' not in f]
np.array(fullPathList)
np.array(folderList)
np.array(parentList)
df_result = pd.DataFrame({'Files':folderList,'Parent':parentList,'FullPath':fullPathList})
Alteryx.write(df_result,1)
您可以直接使用Alteryx目录工具获取文件夹的所有详细信息,该文件夹将提供有关该目录中文件的完整元数据。 只需像*一样传递父文件夹路径* 并启用“包含子目录选项”,该选项将提供所有详细信息。 您不需要python来实现这一点。 一旦有了包含目录数据的表,就可以使用筛选工具获取Alteryx中文件的特定扩展名。 如果你需要更多的帮助,请告诉我。 您可以在此处找到更多详细信息:-
https://help.alteryx.com/current/designer/directory-tool
相关问题 更多 >
编程相关推荐