多文件合并到一个文件

阅读更多
import os
import codecs
inputDir = "D:\\orcltemp\\temp"
outputFile = "D:\\orcltemp\\merge.sql"
fo = codecs.open(outputFile, "w", "GB2312")
for root, dirs, files in os.walk(inputDir, topdown=False):
	for name in files:
		with open(os.path.join(root, name), "r+") as fi:
			total_line_count = sum(1 for line in fi)
		with codecs.open(os.path.join(root, name), "r+") as fi:	
			for i, line in enumerate(fi.readlines()):
				if i>2 and (i 

你可能感兴趣的:(python,IO)