I have a text file with movie details,structure like this;
ID | Rating | Title | Genre |
---|---|---|---|
0 | 4.5 | Amelie (Fabuleux destin d'Amélie Poulain, Le) (2001) | Comedy|Romance|Thriller |
1 | 3.0 | Die Hard (1988) | Action|Crime|Thriller |
2 | 4.0 | Star Wars: Episode VI - Return of the Jedi (1983) | Action|Adventure|Sci-Fi |
3 | 3.5 | Fugitive, The (1993) | Thriller |
4 | 4.5 | Fugitive, The (1993) | Thriller |
5 | 2.5 | Amelie (Fabuleux destin d'Amélie Poulain, Le) (2001) | Comedy|Romance|Thriller |
I want to find the same movies and save them as a new item by taking the average rating of the movies I found.
For example; Fugitive is duplicated on the list. Average rating: 4.0
{'580': ['4.0', 'Jurassic Park (1993)', ['Action', 'Adventure', 'Sci-Fi', 'Thriller']],
'264': ['4.0', 'Mask, The (1994)', ['Action', 'Comedy', 'Crime', 'Fantasy', 'Thriller']],
'370': ['4.5', "Amelie) (2001)", ['Comedy', 'Romance', 'Thriller']],
'312': ['3.0', 'Die Hard (1988)', ['Action', 'Crime', 'Thriller']],
'166': ['3.5', 'Fugitive, The (1993)', ['Thriller']],
'195': ['4.5', 'Fugitive, The (1993)', ['Thriller']]}
I have saved each line in the file as an item in the dictionary. How can I find and average the same items? Thanks.