1
我想從網絡文件夾中找到所有.gz
文件的文件夾路徑。 我有以下script
但它給人error
:將字符串插入到python 3.6.0中的Dataframe中
TypeError: cannot concatenate a non-NDFrame object
在同一
腳本請幫幫忙:
import os
import pandas as pd
adcPath = r'\\ADC\redshift-datasets\BLSCEWAG2016'
gzPath = pd.DataFrame(columns=['Path'], dtype=object)
for path, subdirs, files in os.walk(adcPath):
for name in files:
if name.endswith('.gz'):
gzPath = gzPath.append(path) # Want to insert to dataframe gzPath to export in csv
gzPath = gzPath['Path'].unique()
exportPath = r'D:\Sunil_Work\temp8' + '\\Path.csv'
gzPath.to_csv(exportPath)
@coldspeed,感謝響應。但我可以給路徑:adcPath = r'\\ ADC \ redshift-datasets \ BLSCEWAG2016',我想要從提到的路徑中獲取並非全部 –
但是,如果子文件夾存在,它會給出空白,它只有在我給直接文件夾鏈接包含.gz文件 –
@faithon好吧...編輯我的答案。用'glob'使用'遞歸'標誌。 –