Created
November 28, 2017 23:25
-
-
Save comtom/28d8a7ba8df0436f3136691a819183b1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import time | |
| import datetime | |
| with open('file1.csv', 'w') as output: | |
| with open('combined_data_1.txt', 'r') as f: | |
| currentMovieID = 0 | |
| for line in f: | |
| line = line.strip() | |
| if (line[len(line) - 1] == ":"): | |
| currentMovieID = int(line[0: len(line) - 1]) | |
| else: | |
| (userID, rating, rating_date) = line.split(',') | |
| rating_date = int(time.mktime(datetime.datetime.strptime(rating_date, "%Y-%m-%d").timetuple())) | |
| output.write('%s,%s,%s,%s\n' % (currentMovieID, userID, rating_date, rating)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment