Skip to content

Instantly share code, notes, and snippets.

@talos
Created January 22, 2016 01:15
Show Gist options
  • Save talos/1d60c311e3f557b9bd99 to your computer and use it in GitHub Desktop.
Save talos/1d60c311e3f557b9bd99 to your computer and use it in GitHub Desktop.
Sample of joining together yelp review & business data
import json
def main():
businesses_by_id = {}
with open('yelp_academic_dataset_business.json') as business_file:
# for every line in this file (every business)
# load the json in from that line into an object (json.loads)
#
# save the object to the businesses_by_id dict by its `business_id`
with open('yelp_academic_dataset_review.json') as review_file:
# for every line in this file (every review)
# load the json in from that line into an object (json.loads)
#
# look up the business from businesses_by_id by using the `business_id` in the review object you just loaded
#
# do whatever other processing you want to do now that you've got the business
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment