import threading1
import os
import time
threading1 = []
start = time.clock()
Currentpath = os.getcwd()
print ("Currentpath==> "+Currentpath)
print ("*****************************************")
DirList = os.listdir(Currentpath)
print (DirList)
def Getposition(file):
StrEnd = file[-7:]
if StrEnd == "Sum.txt":
filepath = Currentpath + "\" + folder + "\" + file
print("==> " + filepath)
result = []
with open(filepath, 'r') as f:
for lines in f.readlines():
txts = lines.split(' ')
print(txts[-3:])
tem = ','.join(txts[-3:])
with open(file + '-2.csv', 'a') as fcsv:
fcsv.writelines(tem)
for folder in DirList:
if os.path.isdir(Currentpath+"\"+folder):
print("*****************************************")
print("Now working folder==> "+folder)
Files = os.listdir(Currentpath+"\"+folder)
print(Files)
print("*****************************************")
list1 = range(len(Files))
print(list1)
if name== '__main__' :
for i in list1:
t = threading1.Thread(target=Getposition, args=(Files[i]))
print(threading1)
threading1.append(t)
for i in list1:
threading1[i].start()
for i in list1:
threading1[i].join()
print ("***************Finished!!!***************")
end=time.clock()
times=end-start
print("runtime:"+str(times))