-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path14..py
More file actions
30 lines (23 loc) · 1.13 KB
/
Copy path14..py
File metadata and controls
30 lines (23 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import csv
from collections import Counter
from datetime import datetime
# Counter to store the number of repositories created by each user on weekends
weekend_repo_counts = Counter()
# Open the repositories.csv file and read data
with open('repositories.csv', 'r', encoding='utf-8') as file:
reader = csv.DictReader(file)
for row in reader:
created_at = row.get('created_at', '')
if created_at:
# Convert created_at string to a datetime object
created_date = datetime.fromisoformat(created_at[:-1]) # Remove 'Z' and convert
# Check if the day is Saturday (5) or Sunday (6)
if created_date.weekday() in [5, 6]:
user_login = row['login']
weekend_repo_counts[user_login] += 1 # Increment the count for the user
# Get the top 5 users who created the most repositories on weekends
top_users = weekend_repo_counts.most_common(5)
# Extract the logins of the top users
top_logins = [user[0] for user in top_users]
# Output the top users' logins as a comma-separated string
print(','.join(top_logins))