Advertisement
szabozoltan69

step3.py

Aug 2nd, 2017
301
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.76 KB | None | 0 0
  1. #!/usr/bin/python3
  2. fout= open("F1.csv","w", encoding="ISO-8859-2")
  3. finp= open("F1_.csv",    encoding="ISO-8859-2")
  4.  
  5. d=';'
  6. szurj={}
  7.  
  8. for index,line in enumerate(finp):
  9.     if index==0:
  10.         continue
  11.     line=line.strip()
  12.     x=line.split(";")
  13.  
  14.     try:
  15.         szurj[x[0]+d+x[3]+d+x[6]+d+x[8]]
  16.     except KeyError:
  17.         szurj[x[0]+d+x[3]+d+x[6]+d+x[8]]=x[7]
  18.     else:
  19.         if  int(szurj[x[0]+d+x[3]+d+x[6]+d+x[8]])<int(x[7]):
  20.             szurj[x[0]+d+x[3]+d+x[6]+d+x[8]]=x[7];
  21.  
  22.  
  23. finp.close()
  24. finp= open("F1_.csv",    encoding="ISO-8859-2")
  25. for index,line in enumerate(finp):
  26.     line=line.strip()
  27.     if index==0:
  28.         print(line,file=fout)
  29.         continue
  30.     x=line.split(";")
  31.     if  szurj[x[0]+d+x[3]+d+x[6]+d+x[8]]!=x[7]:
  32.         continue
  33.     s=";".join(x)
  34.     print(s,file=fout)
  35.  
  36. fout.close()
  37. finp.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement