-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path4_follower_loss.py
35 lines (29 loc) · 1.39 KB
/
4_follower_loss.py
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
31
32
33
34
35
# Function to read usernames from a text file and return a set
def read_usernames_from_file(file_path):
with open(file_path, 'r', encoding='utf-8') as file:
return set(line.strip() for line in file.readlines())
# Paths to the extracted usernames files
followers_1_file_path = 'extracted_followers_usernames_24_nov.txt'
followers_2_file_path = 'extracted_followers_usernames_6_jan.txt'
# Read the usernames from both files
followers = read_usernames_from_file(followers_1_file_path)
following = read_usernames_from_file(followers_2_file_path)
# Find users you follow but who do not follow you back
not_following_back = followers - following
# Sort the usernames in alphabetical order
sorted_not_following_back = sorted(not_following_back)
# Output the list of users who don't follow you back
if sorted_not_following_back:
print("Users you follow but who don't follow you back:")
# for username in sorted_not_following_back:
# print(username)
else:
print("Everyone you follow follows you back!")
# Optionally, save the sorted list to a file
with open('follower_loss_1.txt', 'w') as output_file:
if sorted_not_following_back:
output_file.write('\n'.join(sorted_not_following_back))
print("time difference saved to follower_Loss_1.txt")
else:
output_file.write("Everyone you follow follows you back!")
print("No one to save in follower_loss.txt")