#!/usr/bin/env python3 """ Find ALL albums that were dropped from 2020 to 2023 by comparing the lists. """ import csv def normalize_text(text): """Normalize text for comparison""" return text.lower().strip().replace('&', 'and').replace(' ', ' ') def main(): # Read 2020 albums (simplified) albums_2020 = {} with open('rolling_stone_2020_simple.csv', 'r', encoding='utf-8') as file: reader = csv.DictReader(file) for row in reader: key = (normalize_text(row['Artist']), normalize_text(row['Album'])) albums_2020[key] = { 'rank': row['Rank'], 'artist': row['Artist'], 'album': row['Album'] } print(f"šŸ“Š Loaded {len(albums_2020)} albums from 2020 list") # Read 2023 albums (only first 500) albums_2023 = set() new_count = 0 with open('top_500_albums_2023.csv', 'r', encoding='utf-8') as file: reader = csv.DictReader(file) for row in reader: rank = int(row['Rank']) if rank <= 500: key = (normalize_text(row['Artist']), normalize_text(row['Album'])) albums_2023.add(key) if row['Status'] == 'New in 2023': new_count += 1 print(f"šŸ“Š Loaded {len(albums_2023)} albums from 2023 list") print(f"šŸ†• Found {new_count} albums marked as 'New in 2023'") # Find dropped albums dropped_albums = [] for key, album_info in albums_2020.items(): if key not in albums_2023: dropped_albums.append(album_info) # Sort by original 2020 rank dropped_albums.sort(key=lambda x: int(x['rank'])) print(f"\nāŒ Found {len(dropped_albums)} albums dropped from 2020 to 2023:") print("=" * 80) for album in dropped_albums: print(f"#{album['rank']:3s} - {album['artist']} - {album['album']}") print("=" * 80) print(f"\nšŸ“Š Summary:") print(f" - New albums in 2023: {new_count}") print(f" - Dropped albums: {len(dropped_albums)}") print(f" - Match: {'āœ… Yes' if new_count == len(dropped_albums) else 'āŒ No'}") # Save dropped albums list with open('truly_dropped_albums.csv', 'w', newline='', encoding='utf-8') as file: fieldnames = ['Original_Rank_2020', 'Artist', 'Album'] writer = csv.DictWriter(file, fieldnames=fieldnames) writer.writeheader() for album in dropped_albums: writer.writerow({ 'Original_Rank_2020': album['rank'], 'Artist': album['artist'], 'Album': album['album'] }) print(f"\nšŸ’¾ Saved complete list to: truly_dropped_albums.csv") if __name__ == "__main__": main()