0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

pythonで特定のフォルダ内のExcel一覧を再帰的に取得してExcelに書き出す。

Last updated at Posted at 2020-06-04

# 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    
)
0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?