I have a textfile that I want to put into lists.
The textfile looks like this:
New Distribution Votes Rank Title
0000000125 1196672 9.2 The Shawshank Redemption (1994)
0000000125 829707 9.2 The Godfather (1972)
0000000124 547511 9.0 The Godfather: Part II (1974)
0000000124 1160800 8.9 The Dark Knight (2008)
I have tried splitting the list with this code:
x = open("ratings.list.txt","r")
movread = x.readlines()
x.close()
s = raw_input('Search: ')
for ns in movread:
if s in ns:
print(ns.split()[0:100])
Output:
Search: #1 Single
['1000000103', '56', '6.3', '"#1', 'Single"', '(2006)']
But it does not give me the output i want
It splits on the spaces between the Title.
How can I split it into a list without breaking up the title?
Expected output:
Search: #1 Single
Distribution Votes Rank Title
['1000000103', '56', '6.3', '"#1 Single" (2006)']