python合并同类型excel表格 python合并同类型excel表格的方法
newtonnl 人气:0想了解python合并同类型excel表格的方法的相关内容吗,newtonnl在本文为您仔细讲解python合并同类型excel表格的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点: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+;,
复制所选内容,把筛选的数据复制到新的标签页里,可进行均值分析。
加载全部内容