python合并同类型excel表格的方法
本文实例为大家分享了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+;,
复制所选内容,把筛选的数据复制到新的标签页里,可进行均值分析。
相关推荐
diyanpython 2020-11-05
YENCSDN 2020-11-17
lsjweiyi 2020-11-17
houmenghu 2020-11-17
Erick 2020-11-17
HeyShHeyou 2020-11-17
以梦为马不负韶华 2020-10-20
lhtzbj 2020-11-17
夜斗不是神 2020-11-17
pythonjw 2020-11-17
dingwun 2020-11-16
lhxxhl 2020-11-16
坚持是一种品质 2020-11-16
染血白衣 2020-11-16
huavhuahua 2020-11-20
meylovezn 2020-11-20
逍遥友 2020-11-20