简体   繁体   English

如何读取不同 Pandas Dataframes 中的多个 excel 文件

[英]How to read multiple excel files in Different Pandas Dataframes

I have collection of excel files containing similar datasets.我收集了包含类似数据集的 excel 文件。 I want it to be read by different Pandas dataframes.我希望它被不同的 Pandas 数据帧读取。

import glob
import pandas as pd

path=r"C:users/me/desktop/ExcelData"

files=glob.glob('*.xls')
for f in files:
      df[f]=pd.read_excel(f)
import glob
import pandas as pd
import os

path=r"C:\\users\\me\\desktop\\ExcelData\\"
csv_files = glob.glob(os.path.join(path, "*.xls"))

dfl=[]
for f in csv_files:
    x= pd.read_excel(f)
    dfl.append(x)
import pandas as pd
import os
import glob

path = r"C:users/me/desktop/ExcelData"
files = glob.glob(path + "\*.xls")

finalexcelsheet = pd.DataFrame()

for file in files:
    df = pd.concat(pd.read_excel(file, sheet_name = None), ignore_index=True, 
    sort=False)
    finalexcelsheet = finalexcelsheet.append(df, ignore_index = True)

print(finalexcelsheet)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将源文件中的 excel 文件动态读取到 python 中的不同数据帧中 - How to read excel files dynamically in a source file into different dataframes in python 如何将多个熊猫数据帧输出到具有不同尺寸的同一csv或excel - How to output multiple pandas dataframes to the same csv or excel with different dimensions 将 Pandas 数据框写入多个 excel 文件 - Writing pandas dataframes to multiple excel files 打开多个 Excel 文件以分隔 Pandas 数据框 - Open multiple Excel files to separate Pandas dataframes 将多个csv文件读取到单独的pandas数据帧中 - Read multiple csv files into separate pandas dataframes 如何快速读取多个excel文件,每个文件中都有多个工作表-熊猫? - How to quickly read in multiple excel files with multiple sheets in each - Pandas? 如何将多个熊猫数据框保存到 Excel - How to save multiple pandas dataframes to Excel 如何将不同数据框中的多列与 Pandas 进行比较 - How to compare Multiple columns in different Dataframes with Pandas 如何使用 spark.read.jdbc 读取不同 Pyspark 数据帧中的多个文件 - How to Read multiple files in different Pyspark Dataframes using spark.read.jdbc 使用 Pandas 将 Excel 工作簿的多张工作表放入不同的数据框中 - Multiple sheets of an Excel workbook into different dataframes using Pandas
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM