#-*- coding:utf-8 _*-# import os #---------Parameter definition,start---------# lastStateRecord = None currantStateRecord = None finalSelectionState = None compoundParameterList = [] luCiStart = False daiJStart = False defaultState = None yearMouthZu = ['201709','201710','201711','201712','201801','201802','201803','201804'] #--------Parameter definition,end------------# #cvsPath = '/home/opt/data/' + yearMouth + '/IOTF81' + str(numberFile) + '_RunDataEntity_' + yearMouth + '.csv' #------------Context awareness function start-------------# def contextAwareness(): global currantStateRecord,lastStateRecord,finalSelectionState,defaultState print(currantStateRecord,lastStateRecord) #----------------Using count == 2 instead of count == 1 is because the files read here contain field properties.---------------------# if count == 2 and currantStateRecord != None: # print('this is currantStateRecord:',currantStateRecord,'this two statue is',float(rowItems[49]) == currantStateRecord) lastStateRecord = currantStateRecord finalSelectionState = currantStateRecord else: if float(currantStateRecord) - float(lastStateRecord) > 3 or float(currantStateRecord) - float(lastStateRecord) < 0 and float(currantStateRecord) - float(lastStateRecord) > -8: # print('this is lastStateRecord:',lastStateRecord,'this two statue is',float(rowItems[49]) == lastStateRecord) finalSelectionState = lastStateRecord else: # print('this is currantStateRecord:',currantStateRecord,'this two statue is',float(rowItems[49]) == currantStateRecord) lastStateRecord = currantStateRecord finalSelectionState = currantStateRecord print(finalSelectionState) #------------Context awareness function end---------------# cvsMarkPath = '/home/opt/data/marked_data/result.csv' with open(cvsMarkPath,'a+') as cvsMarkObject: for itemYM in yearMouthZu: yearMouth = itemYM for fileNum in range(999): numberFile = format(fileNum,'03d') # print(numberFile) cvsPath = '/home/opt/data/' + yearMouth + '/IOTF81' + str(numberFile) + '_RunDataEntity_' + yearMouth + '.csv' if os.path.exists(cvsPath): print(cvsPath) count = 0 with open(cvsPath) as csvObject: luCiStart = False daiJStart = False for rowPer in csvObject: #----------------------------------------------------------The first floor,start-----------------------------------------------------------# count += 1 rowItems = rowPer.split(',',-1) #----------------------------------------------------------The first stage,start----------------------------------------------------------# try: float(rowItems[22]) except Exception , err: if(count == 1): continue else: print('the problem have') else: print('num:',count,rowItems[22]) if float(rowItems[22]) > 7500: # print('this is :shengwen',rowItems[49],'this two statue is',float(rowItems[49]) == 1 ) currantStateRecord = 1 contextAwareness() if float(finalSelectionState) == 1 and luCiStart == False: luCiStart = True daiJStart = False print('running write starttime') cvsMarkObject.write('number:'+ str(count) + ','+ '/IOTF81' + str(numberFile) + '_RunDataEntity_' + yearMouth+','+'start:'+','+str(rowItems[1])+',') continue elif float(rowItems[22]) <= -80: if float(rowItems[12]) != 0: # print('this is :tuihuo',rowItems[49],'this two statue is',float(rowItems[49]) == 7 ) currantStateRecord = 7 contextAwareness() continue #---------------------function chuli elif float(rowItems[12]) == 0: if float(rowItems[8]) > 15000 and float(rowItems[13]) > 10: # print('this is lengque',rowItems[49],'this two statue is',float(rowItems[49]) == 8 ) currantStateRecord = 8 contextAwareness() continue elif float(rowItems[13]) < 0.1 and float(rowItems[13]) > 0: # print('this is lengque',rowItems[49],'this two statue is',float(rowItems[49]) == 8 ) currantStateRecord = 8 contextAwareness() continue elif float(rowItems[14]) > 0: # print('this is daiji',rowItems[49],'this two statue is',float(rowItems[49]) == 0 ) currantStateRecord = 0 contextAwareness() print(finalSelectionState) if float(finalSelectionState) == 0 and daiJStart == False: daiJStart = True luCiStart = False print('running write endtime') cvsMarkObject.write(','+'number:'+str(count)+','+ '/IOTF81' + str(numberFile) + '_RunDataEntity_' + yearMouth+','+'end:'+','+str(rowItems[1])+'\n') continue else: # print('this is kailu',rowItems[49],'this two statue is',float(rowItems[49]) == 9 ) currantStateRecord = 9 contextAwareness() continue elif float(rowItems[22]) > -20 and float(rowItems[22]) < 0: if float(rowItems[15]) > 0 and float(rowItems[46]) == 0: # print('this is :shengzhang',rowItems[49],'this two statue is',float(rowItems[49]) == 5) currantStateRecord = 5 contextAwareness() continue #---------------The growth is sometimes negative, so 'rowItems[15]) == 0' is removed. elif float(rowItems[46]) == 0 and float(rowItems[8]) >= 0 and float(rowItems[8]) <= 20 and float(rowItems[21] > 0): # print('this is :shengzhang',rowItems[49],'this two statue is',float(rowItems[49]) == 5) currantStateRecord = 5 contextAwareness() continue elif float(rowItems[15]) == 0 and float(rowItems[46]) > 0 and float(rowItems[21] > 0): # print('this is fangjian',rowItems[49],'this two statue is',float(rowItems[49]) == 4 ) currantStateRecord = 4 contextAwareness() continue #-------------------------------------------------------------The first floor, end--------------------------------------------------------# #-------------------------------------------------------------The second floor, end--------------------------------------------------------# print(count) print('finished!')
浙公网安备 33010602011771号