Specifying Keys in txt file Dictionary - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Data Science (https://python-forum.io/forum-44.html) +--- Thread: Specifying Keys in txt file Dictionary (/thread-26491.html) |
Specifying Keys in txt file Dictionary - catsrule - May-03-2020 So I am trying to build a dictionary that maps the key value to a specific value in a txt file. Its a txt file about movie reviews and I am trying to separate it into random reviews by each author. The format of the text file is |reviewId userId itemId rating title content|. So how would I specify that I want 100 random reviews from each author (userID) and place each all the random reviews into separate text files for test/train data. RE: Specifying Keys in txt file Dictionary - Larz60+ - May-03-2020 use a dictionary: 'Gone With the Wind': { 'stars': { 'Vivien Leigh': 'Scarlett O'Hara', 'William Clark Gable': 'Rhett Butler', ... }, 'other stuff': { } } |