Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import csv
- defaulters = []
- MIN_PERCENT = 70
- with open("input.csv") as f:
- reader = csv.reader(f)
- for i, row in enumerate(reader):
- if i == 0:
- continue
- attendance = sum(map(int, row[2:]))
- total_days = len(row)
- if attendance < total_days * (MIN_PERCENT / 100):
- defaulters.append(
- [
- row[0],
- row[1],
- attendance,
- total_days,
- round((attendance / total_days) * 100, 2),
- ]
- )
- with open("defualter.csv", "w") as f:
- writer = csv.writer(f)
- writer.writerow(["Roll", "Name", "Count", "Total", "perc"])
- writer.writerows(defaulters)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement