from datetime import date
infile = open("H:\\Input.txt","r")
outfile = open("H:\\Output.txt","w")
lineRead = (infile.read()).split("\n")
infile.close()
yr = []
for r in range(0,len(lineRead)):
ID=""
temp = lineRead[r].split(" ")
s = temp[1][0]+ temp[1][1]+temp[1][2]+temp[1][3]
y = int(s)
yr.append(y)
m = int(temp[1][5]+temp[1][6])
d = int(temp[1][8]+temp[1][9])
d0 = date(y, 1, 1)
d1 = date(y, m, d)
delta = d1 - d0
t = delta.days+1
Cnt = yr.count(y)
if(Cnt<10): c = "00"+str(Cnt)
if(Cnt>9 and Cnt<100): c = "0"+str(Cnt)
if(Cnt>99): c = str(Cnt)
if(temp[2]=='F' or temp[2]=='f'):
t = t+500
ID = ID + str(y) + str(t) + c
print("%s\t%s\t%s\t%s\n"%(temp[0],temp[1],temp[2],ID))
outfile.write("%s\t%s\t%s\t%s\n"%(temp[0],temp[1],temp[2],ID))
outfile.close()
Comments
Leave a comment