📜  熊猫读取文件夹中的每个 xlsx 文件 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:08.158000             🧑  作者: Mango

代码示例3
import os
import pandas as pd
import openpyxl as excel
import glob



#setting up path

path = 'data_inputs'
extension = 'xlsx'
os.chdir(path)
files = [i for i in glob.glob('*.{}'.format(extension))]

#Grouping files - brings multiple files of same type together in a list 

wild_groups = ([s for s in files if "wild" in s])
domestic_groups = ([s for s in files if "domestic" in s])

#Sets up a dictionary associated with the file groupings to be called in another module 
file_names = {"WILD":wild_groups, "DOMESTIC":domestic_groups}
...