简体   繁体   English

如何将 excel 文件与不同文件夹合并

[英]How to combine excel files with different folders

I am new to python, have got a task of combining the excel files.我是 python 的新手,我的任务是合并 excel 文件。 I have 100 folders, each folder have 2 sub folders and in each sub folder have 24 excel files.我有 100 个文件夹,每个文件夹有 2 个子文件夹,每个子文件夹中有 24 个 excel 文件。 now I have to find maximum value and minimum values of each and every 24 files and that value I have to concatenate with parent excel file (this one have to do for all 24 files).现在我必须找到每个 24 个文件的最大值和最小值,并且我必须将这个值与父 excel 文件连接(这个必须对所有 24 个文件做)。 then i have to concatenate all 24 files have to write on first column of excel file.然后我必须连接所有 24 个文件必须写入 excel 文件的第一列。 and this should be repeat for all the 100 folder, so finally i have to get single excel file with 100 column.这应该对所有 100 个文件夹重复,所以最后我必须得到一个包含 100 列的 excel 文件。 presently I am using manual method for every file and it is over writing is become complicated and time consuming please someone help me to get-out of that method目前我对每个文件都使用手动方法,并且过度写入变得复杂且耗时,请有人帮助我摆脱这种方法

data12 = pd.read_excel (r'C:\Users\Videos\1.xlsx')
A= max(data12)   
C= min(data12) 
frame_data= [data12, A, C]
result = pd.concat(frame_data)
result.to_excel("output1.xlsx", sheet_name='modify_data', index=False) 

You can use python glob library to browse through all the files in all the folders.您可以使用 python glob 库来浏览所有文件夹中的所有文件。 You just need to pass the name of master folder.您只需要传递主文件夹的名称。 and then use one loop to read all the files one by one.然后使用一个循环将所有文件一一读取。

Link for reference: Python glob multiple filetypes参考链接: Python glob 多种文件类型

暂无
暂无

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

相关问题 如何将 5 个同名但位于 5 个不同文件夹中的 Excel 文件合并? - How to combine 5 Excel files with the same name but in 5 different folders? 尝试组合来自不同 excel 文件的列 - trying to combine columns from different excel files 如何使用 Python 将多个 CSV 文件合并为一个具有不同工作表的 Excel 文件 - How do I combine multiple CSV files into one excel files with different sheets using Python 如何在 python 中以 dataframe 格式一次打开位于不同子文件夹中的多个 excel 压缩文件(.gz 文件)? - How to open multiple zipped excel files(.gz file) located in different sub folders at once in dataframe format in python? 如何将文件夹中的所有文件列出到 excel 表中 - how to list all files in folders into an excel sheet 如何组合 Python 中多个文件夹中的多个 CSV 文件? - how to combine multiple CSV files from multiple folders in Python? 如何将多个文件夹中的相同文件合并为一个文件s3 - How to combine same files in mutliple folders into one file s3 如何将每 500 个文件移动到不同的文件夹中 - How to move every 500 files into different folders python如何访问不同文件夹中的所有文件 - python how to access all the files that are in different folders 将多个文件夹和子文件夹中的几个excel文件合并到一个熊猫数据框中 - Combine several excel files from multiple folders and subfolders into one pandas dataframe
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM