markedCodeVersion(2018/05/16)

Posted on 2018-05-16 17:05  Terry_Sun  阅读(154)  评论(0)    收藏  举报
#-*- coding:utf-8 _*-


import os

#cvsPath = '/home/opt/data/201709/IOTF81301_RunDataEntity_201709.csv'


#---------Parameter definition,start---------#    
lastStateRecord = None
lastRowdata = None
compoundParameterList = []
#--------Parameter definition,end------------# 

#year_mouth =''
#number_file=''

#cvsPath = '/home/opt/data/' + year_mouth + '/IOTF81' + str(number_file) + '_RunDataEntity_' + year_mouth + '.csv'

yearMouthZu = ['201709','201710','201711','201712','201801','201802','201803','201804']
statusArray = ['daiji','shengwen','kaozijing','yinjing','fangjian','shengzhang','tila','tuihuo','lengque','kailu']
print(statusArray)
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
            markedCvsPath =  '/home/opt/data/marked_data/' +  yearMouth + '/IOTF81' + str(numberFile) + '_RunDataEntity_' + yearMouth + '.csv'
            with open(cvsPath) as csvObject:
                with open(markedCvsPath,'a+') as markedCvsPathObject:
                    for rowPer in csvObject:
#----------------------------------------------------------The first floor,start-----------------------------------------------------------#
                        count += 1
                        rowItems = rowPer.split(',',-1)
#----------------------------------------------------------The first stage,start----------------------------------------------------------#

#-------------------------------------------------------------check_para_saft-------------------------------------------------------------#
                        try:
                            float(rowItems[8]), float(rowItems[12]), float(rowItems[13]), float(rowItems[14])
                            float(rowItems[15]), float(rowItems[21]), float(rowItems[22]), float(rowItems[46])
                            float(rowItems[49])
                        except Exception , err:
                            continue
                        else:
#-----------------------------------------------------------------------------------------------------------------------------------------#
                            try:
                                float(rowItems[22])
                            except Exception , err:
                                continue
                            else:
#                                print('num:',count,rowItems[22])
                                if float(rowItems[22]) > 7500:
                                    #print('this is :'+statusArray[1],rowItems[49],'this two statue is',float(rowItems[49]) == 1 )
                                    markedCvsPathObject.write(str(count)+','+str(1)+'\n')
                                    continue
                                elif float(rowItems[22]) <= -80:
                                    if float(rowItems[12]) != 0:
                                        #print('this is :'+statusArray[7],rowItems[49],'this two statue is',float(rowItems[49]) == 7 )
                                        markedCvsPathObject.write(str(count)+','+str(7)+'\n')
                                        continue
#-----------------------------------------------------------------------function chuli-----------------------------------------------------#
                                    elif float(rowItems[12]) == 0:
                                        if float(rowItems[8]) > 15000 and float(rowItems[13]) > 10:
                                            #print('this is :'+statusArray[8],rowItems[49],'this two statue is',float(rowItems[49]) == 8 )
                                            markedCvsPathObject.write(str(count)+','+str(8)+'\n')
                                            continue
                                        elif float(rowItems[13]) < 0.1 and float(rowItems[13]) > 0:
                                            #print('this is :'+statusArray[8],rowItems[49],'this two statue is',float(rowItems[49]) == 8 )
                                            markedCvsPathObject.write(str(count)+','+str(8)+'\n')
                                            continue
                                        elif float(rowItems[14]) > 0:
                                            #print('this is :'+statusArray[0],rowItems[49],'this two statue is',float(rowItems[49]) == 0 )
                                            markedCvsPathObject.write(str(count)+','+str(0)+'\n')
                                            continue
                                        else:
                                            #print('this is :'+statusArray[9],rowItems[49],'this two statue is',float(rowItems[49]) == 9 )
                                            markedCvsPathObject.write(str(count)+','+str(9)+'\n')
                                            continue         
                                elif float(rowItems[22]) > -20 and float(rowItems[22]) < 0:
                                    if float(rowItems[15]) > 0 and float(rowItems[46]) == 0:
                                        #print('this is :'+statusArray[5],rowItems[49],'this two statue is',float(rowItems[49]) == 5)
                                        markedCvsPathObject.write(str(count)+','+str(5)+'\n')
                                        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:
                                        #print('this is '+statusArray[5],rowItems[49],'this two statue is',float(rowItems[49]) == 5)
                                        markedCvsPathObject.write(str(count)+','+str(5)+'\n')
                                        continue
                                    elif float(rowItems[15]) == 0 and float(rowItems[46]) > 0:
                                        #print('this is :'+statusArray[4],rowItems[49],'this two statue is',float(rowItems[49]) == 4 )
                                        markedCvsPathObject.write(str(count)+','+str(4)+'\n')
                                        continue
#---------------------------------------------------------The second stage,start-----------------------------------------------------------#
                                if float(rowItems[12]) <= 1:
                                    if float(rowItems[8]) > 15000 and float(rowItems[13]) > 10:
                                        #print('this is :'+statusArray[8],rowItems[49],'this two statue is',float(rowItems[49]) == 8 )
                                        markedCvsPathObject.write(str(count)+','+str(8)+'\n')
                                        continue
                                    else:
                                        #print('this is :'+statusArray[0],rowItems[49],'this two statue is',float(rowItems[49]) == 0 )
                                        markedCvsPathObject.write(str(count)+','+str(0)+'\n')
                                        continue
                                elif float(rowItems[21]) > 5:
                                    #print('this is :'+statusArray[3],rowItems[49],'this two statue is',float(rowItems[49]) == 3 )
                                    markedCvsPathObject.write(str(count)+','+str(3)+'\n')
                                    continue
                                else:
                                    try: 
                                        float(rowItems[49]) 
                                    except Exception ,err: 
                                        #print('this is :'+statusArray[2],rowItems[49],'this two statue is',False)
                                        markedCvsPathObject.write(str(count)+','+str(2)+'\n')
                                    else:
                                        #print('this is :'+statusArray[2],rowItems[49],'this two statue is',float(rowItems[49]) == 2)
                                        markedCvsPathObject.write(str(count)+','+str(2)+'\n')
                                        continue
                #------------Compound parameter,start-------------#

                #------------Compound parameter,end---------------#
                                lastRowdata = rowPer
                #-------------------------------------------------------------The first floor, end--------------------------------------------------------#

                #-------------------------------------------------------------The second floor, end--------------------------------------------------------#

                    print(count)
        else:
            continue
print('mark finished!!!')
View Code

 

博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3