Skip to content

Instantly share code, notes, and snippets.

@Siddhartha90
Created January 26, 2014 00:37
Show Gist options
  • Save Siddhartha90/8626142 to your computer and use it in GitHub Desktop.
Save Siddhartha90/8626142 to your computer and use it in GitHub Desktop.
another script to pull out movie from the movies.dat file
def main():
myfile = open('result.txt', 'r')
myfile2 = open('movies.txt', 'r')
myfile3 = open('finalrecos.txt', 'w')
content = myfile2.read()
i = 0
for line in myfile:
m = re.search(r'(?<=RecommendedItem\[item:)(\d+)',line)
i+=1
n = re.search(r'(?<='+m.group(0)+r'\:\:)(.+)(?=::)',content)
myfile3.write('User ' + str(i) + ' will like the movie "')
myfile3.write(n.group(0))
myfile3.write('" the best\n')
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment