list2Txt.py

import os
import logging
import datetime
from DataCleaning.library.functions.appendString2Txt import *
from DataCleaning.library.functions.createTxt import *
from DataCleaning.library.functions.processBar import *

def list2Txt(tempListAll, outputFileName, wd='', sep = "|", inputPercentage = -1, newFile = False):
# startTime = datetime.datetime.now()
tempWd = os.getcwd()
if wd != '':
os.chdir(wd)
if newFile:
createTxt("", outputFileName, wd)
strLine = ''
for i in range(len(tempListAll)):
strLine += sep.join(tempListAll[i]) + '\n'
if inputPercentage != -1:
processBar(i, len(tempListAll), inputPercentage=inputPercentage)
else:
processBar(i, len(tempListAll))
if i % 10000 == 0:
strLine = strLine.replace("'", "''")
appendString2Txt(strLine, outputFileName, wd)
strLine = ""
strLine = strLine.replace("'", "''").strip()
appendString2Txt(strLine, outputFileName, wd)
os.chdir(tempWd)
# endTime = datetime.datetime.now()
# logging.info("time spent on generating " + str(len(tempListAll)) + " lines in " + outputFileName + ": " + str(endTime - startTime))
上一篇:C#与三菱FX2NPLC的RS232接口通讯(Read)


下一篇:selenium学习笔记--java