Advertisement
Guest User

Untitled

a guest
Dec 12th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. import csv
  2. with open("lab9_files/ex3_input.csv","r",encoding="utf-8") as f:
  3. d = csv.DictReader(f)
  4. dic = {}
  5. for i in d:
  6. nota=int(i["NOTA_EA"])
  7. specializare = i["Specializare"].lower()
  8. if specializare in dic.keys():
  9. dic[specializare][0] +=1
  10. if dic[specializare][1]<nota and dic[specializare][1]>0:
  11. dic[specializare][1]=nota
  12. if dic[specializare][2]>nota:
  13. dic[specializare][2]=nota
  14.  
  15. else:
  16. dic[specializare] = [1,nota,nota]
  17. for i in d:
  18. nota=int(i["NOTA_EA"])
  19.  
  20. with open("out2.csv","w",encoding="utf-8") as g:
  21. csv = csv.writer(g)
  22. csv.writerow(["Specializare","Numar elevi","minim","maxim"])
  23. for i,j in dic.items():
  24. csv.writerow([i,j])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement