Advertisement
AppajiC

Untitled

Nov 14th, 2022
705
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.75 KB | None | 0 0
  1. import csv
  2.  
  3.  
  4. defaulters = []
  5. MIN_PERCENT = 70
  6.  
  7. with open("input.csv") as f:
  8.     reader = csv.reader(f)
  9.     for i, row in enumerate(reader):
  10.         if i == 0:
  11.             continue
  12.         attendance = sum(map(int, row[2:]))
  13.         total_days = len(row)
  14.         if attendance < total_days * (MIN_PERCENT / 100):
  15.             defaulters.append(
  16.                 [
  17.                     row[0],
  18.                     row[1],
  19.                     attendance,
  20.                     total_days,
  21.                     round((attendance / total_days) * 100, 2),
  22.                 ]
  23.             )
  24. with open("defualter.csv", "w") as f:
  25.     writer = csv.writer(f)
  26.     writer.writerow(["Roll", "Name", "Count", "Total", "perc"])
  27.     writer.writerows(defaulters)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement