#!/usr/bin/env python3 """ Update the main CSV with the correct 8 dropped albums, removing all incorrect entries. """ import csv def main(): # The 8 correct dropped albums correct_dropped = [ {'rank': 48, 'artist': 'Bob Marley and the Wailers', 'album': 'Legend'}, {'rank': 170, 'artist': 'Cream', 'album': 'Disraeli Gears'}, {'rank': 351, 'artist': 'Roxy Music', 'album': 'For Your Pleasure'}, {'rank': 358, 'artist': 'Sonic Youth', 'album': 'Goo'}, {'rank': 430, 'artist': 'Elvis Costello', 'album': 'My Aim Is True'}, {'rank': 437, 'artist': 'Primal Scream', 'album': 'Screamadelica'}, {'rank': 466, 'artist': 'The Beach Boys', 'album': 'The Beach Boys Today!'}, {'rank': 491, 'artist': 'Harry Styles', 'album': 'Fine Line'} ] # Read current data, keeping only ranks 1-500 updated_albums = [] 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: updated_albums.append(row) print(f"✅ Kept {len(updated_albums)} albums from ranks 1-500") # Add the 8 correct dropped albums for i, dropped in enumerate(correct_dropped, 1): updated_albums.append({ 'Rank': str(500 + i), 'Artist': dropped['artist'], 'Album': dropped['album'], 'Status': f"Dropped (was #{dropped['rank']} in 2020)", 'Info': '', 'Description': '' }) print(f"✅ Added {len(correct_dropped)} correct dropped albums") # Write updated CSV with open('top_500_albums_2023.csv', 'w', newline='', encoding='utf-8') as file: fieldnames = ['Rank', 'Artist', 'Album', 'Status', 'Info', 'Description'] writer = csv.DictWriter(file, fieldnames=fieldnames) writer.writeheader() writer.writerows(updated_albums) print(f"✅ Updated CSV with {len(updated_albums)} total albums (500 + 8 dropped)") print(f"📁 Saved to: top_500_albums_2023.csv") if __name__ == "__main__": main()