python合并同类型excel表格的方法
作者:newtonnl 时间:2022-05-08 03:51:52
本文实例为大家分享了python合并同类型excel表格的具体代码,供大家参考,具体内容如下
python脚本如下,验证有效。
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import os, csv
class CSVTopoIreator:
def __init__(self, filename):
self.infile = open(filename, 'rb')
self.reader = csv.reader(self.infile)
def __iter__(self):
return self
def next(self):
try:
row = self.reader.next()
except StopIteration:
self.infile.close()
raise StopIteration
return row
def main():
csvfile = file('csv_test.csv', 'wb')
writer = csv.writer(csvfile,delimiter=',',dialect='excel')
writer.writerow(['Items', 'Measure', 'Result'])
for (dirpath, dirnames, filenames) in os.walk('.'):
for name in filenames:
if name != "new1.py" or name != "niniubi.csv":
filename = dirpath + '/' + name
print "csv filename:", filename
ireator = CSVTopoIreator(filename)
#writer.writerow(ireator)
for a in ireator:
print a
writer.writerow(a)
csvfile.close()
if __name__ == '__main__':
main()
合并当前文件夹里csv文件到一个excel表里,筛选需要的数据,excel2007里面alt+;,
复制所选内容,把筛选的数据复制到新的标签页里,可进行均值分析。
来源:https://blog.csdn.net/newtonnl/article/details/52632000
标签:python,合并,excel
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
python爬取免费代理并验证代理是否可用
2021-12-24 20:02:48
Python下载指定页面上图片的方法
2023-08-16 09:32:37
客户端JavaScript代码封装
2008-12-26 18:10:00
Python fileinput模块使用实例
2021-11-28 09:01:18
Python开发的实用计算器完整实例
2023-07-25 17:11:53
![](https://img.aspxhome.com/file/2023/1/60301_0s.png)
python中asyncio异步编程学习
2022-10-20 06:19:37
Python基于os.environ从windows获取环境变量
2022-09-18 01:42:45
asp如何编写一个小数转换分数的函数?
2009-11-08 19:01:00
Python装饰器decorator用法实例
2023-02-06 23:26:43
Python中摘要算法MD5,SHA1简介及应用实例代码
2023-12-12 00:36:41
Javascript Closures (2)
2009-03-18 12:22:00
JavaScript定时器实现的原理分析
2023-08-23 10:24:16
![](https://img.aspxhome.com/file/2023/4/56094_0s.jpg)
段正淳的css笔记(5)未知图片垂直居中的方法
2007-11-01 22:06:00
阿里巴巴中秋节logo设计的艰辛曲折过程
2008-09-11 17:15:00
![](https://img.aspxhome.com/file/UploadPic/20089/11/2008911171924597s.jpg)
基于OpenCV实现视频循环播放
2023-07-13 09:10:33
Python反射机制案例超详细讲解
2022-08-06 16:24:53
![](https://img.aspxhome.com/file/2023/4/75284_0s.png)
介绍Python的Django框架中的静态资源管理器django-pipeline
2023-11-12 00:10:35
python 使用装饰器并记录log的示例代码
2022-02-17 02:15:03
学习python之编写简单乘法口诀表实现代码
2021-11-12 20:19:20
Python控制windows系统音量实现实例
2022-07-29 12:09:46
![](https://img.aspxhome.com/file/2023/0/95210_0s.png)