所以我又开始尝试自动化一些东西。我的最终任务是合并Excel文件中包含文件名中清理的数据,并合并这些文件中名为LOV的选项卡中的数据。所以基本上它必须进入一个文件夹,文件夹中有两个文件,其中一个文件在命名中有单词Clean Up,是一个.xlsx文件。我只需要读取这些文件,然后将标签LOV中的数据拉到一个大文件中。---所以这就是我的最终目标。我刚刚开始,我不在附近,但现在你知道最后的比赛。你知道吗
目前我被困只是在主文件夹的文件夹名称列表,所以我至少知道它得到那里哈哈
import os
import glob
import pandas as pd
# assigns directory location to PCC Folder
os.chdir('V:/PCC Clean Up Project 2017/_DCS Data SWAT Project/PCC Files
Complete Ready to Submit/Brake System Parts')
FolderList = glob.glob('')
print(FolderList)
如果只需要当前目录中的文件夹列表,可以使用
os.path
。其工作原理如下:这将为您提供当前目录中所有文件夹的列表。你知道吗
阅读更多关于
os.walk
here。你知道吗然后可以使用
os.chdir
进入其中一个子目录:编辑
首先你的问题很难理解。但据我所知,你需要遍历文件夹和子文件夹,你可以用
相关问题 更多 >
编程相关推荐