# import libraries
import os
import pandas as pd
from glob import glob
# Configure Folder path
mybooks = glob(r"FOLDERPATH\**\*.xls*",recursive=True)
df = []
for mybook in mybooks:
df.append([mybook,os.path.basename(mybook)])
# Exchange ListObject to Dataframe
df = pd.DataFrame(df)
# Dump to ExcelFile
outputFilename = "filename.xlsx"
outputFolder = r"filepath"
outputFileFullpath = outputFolder + "\\" + outputFilename
df.to_excel(outputFileFullpath,'List')
print(
"ファイルを出力が終了しました。 \n\n\n" +
"ファイル出力場所: " + outputFolder + "\n" +
"ファイル名: " + outputFilename
)
More than 3 years have passed since last update.
pythonで特定のフォルダ内のExcel一覧を再帰的に取得してExcelに書き出す。
Last updated at Posted at 2020-06-04
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme