Guest User

Untitled

a guest
Jan 5th, 2013
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.72 KB | None | 0 0
  1. '''
  2. # movies.txt
  3. 0000000125  884871   9.2  The Shawshank Redemption (1994)
  4. 0000000125  641051   9.2  The Godfather (1972)
  5. 0000000124  411469   9.0  The Godfather: Part II (1974)
  6. 0000000124  689029   8.9  Pulp Fiction (1994)
  7. 0000000124  271377   8.9  Il buono, il brutto, il cattivo. (1966)
  8. 0000000133  218000   8.9  12 Angry Men (1957)
  9. 0000000124  867314   8.9  The Dark Knight (2008)
  10. 0000000124  457446   8.9  Schindler's List (1993)
  11. 0000000124  632940   8.8  The Lord of the Rings: The Return of the King (2003)
  12. 0000000124  675911   8.8  Fight Club (1999)
  13. 0000000124  441444   8.8  Star Wars: Episode V - The Empire Strikes Back (1980)
  14. 0000000233  370957   8.8  One Flew Over the Cuckoo's Nest (1975)
  15. 0000000124  657824   8.8  The Lord of the Rings: The Fellowship of the Ring (2001)
  16. 0000000124  683062   8.7  Inception (2010)
  17. 0000000233  389548   8.7  Goodfellas (1990)
  18. 0000000123  495281   8.7  Star Wars (1977)
  19. 0000000124  141413   8.7  Shichinin no samurai (1954)
  20. 0000000123  645235   8.7  The Matrix (1999)
  21. 0000000123  576965   8.7  Forrest Gump (1994)
  22. 0000000133  291057   8.7  Cidade de Deus (2002)
  23. '''
  24.  
  25. top_20 = []
  26. with open('movies.txt') as f:
  27.     for movies in f:
  28.         temp = movies.split('  ', 3)
  29.         temp = [i.strip() for i in temp]
  30.         temp = temp[:3] + [i.strip() for i in temp[-1].split('(')]
  31.         temp = temp[:4] + temp[-1].split(')')
  32.         temp = temp[:5]
  33.         top_20.append(temp)
  34.  
  35. print top_20
  36.  
  37. [['0000000125', '884871', '9.2', 'The Shawshank Redemption', '1994'], ['0000000125', '641051', '9.2', 'The Godfather', '1972'], ['0000000124', '411469', '9.0', 'The Godfather: Part II', '1974'], ['0000000124', '689029', '8.9', 'Pulp Fiction', '1994'], ['0000000124', '271377', '8.9', 'Il buono, il brutto, il cattivo.', '1966'], ['0000000133', '218000', '8.9', '12 Angry Men', '1957'], ['0000000124', '867314', '8.9', 'The Dark Knight', '2008'], ['0000000124', '457446', '8.9', "Schindler's List", '1993'], ['0000000124', '632940', '8.8', 'The Lord of the Rings: The Return of the King', '2003'], ['0000000124', '675911', '8.8', 'Fight Club', '1999'], ['0000000124', '441444', '8.8', 'Star Wars: Episode V - The Empire Strikes Back', '1980'], ['0000000233', '370957', '8.8', "One Flew Over the Cuckoo's Nest", '1975'], ['0000000124', '657824', '8.8', 'The Lord of the Rings: The Fellowship of the Ring', '2001'], ['0000000124', '683062', '8.7', 'Inception', '2010'], ['0000000233', '389548', '8.7', 'Goodfellas', '1990'], ['0000000123', '495281', '8.7', 'Star Wars', '1977'], ['0000000124', '141413', '8.7', 'Shichinin no samurai', '1954'], ['0000000123', '645235', '8.7', 'The Matrix', '1999'], ['0000000123', '576965', '8.7', 'Forrest Gump', '1994'], ['0000000133', '291057', '8.7', 'Cidade de Deus', '2002']]
Advertisement
Add Comment
Please, Sign In to add comment