No matter how much time I’m given, I always wait until the last minute to get my labs done. This lab was no different. Lab 2 was very straightforward. The hardest part of Lab 1 was getting up and running on EC2. The hardest part of Lab2 was figuring out JSON and that was easy.
It wasn’t clear in the lab description if we were supposed to download the JSON data from S3 and use that data statically or if we were supposed to use http to load the JSON data dynamically from S3. I’m doing the latter. Fetching data via http is trivial using Python. I wrote the following function to fetch data from a URL and run the JSON parser on it:
def getJson(url): h = urllib.urlopen(url) data = None for line in h.readlines(): if data == None: data = line else: data += line return json.read(data)
This function requires you to import json and import urllib. Using this function, it was easier to load the JSON data over http then to load it from the file system because it removed the step of having to copy all the JSON data from S3 to my EC2 instance.
So now it’s on to Lab 3! Ok. Who am I kidding? Lab 3 will get done the night before it’s due.
RSS feed for comments on this post · TrackBack URI
Leave a reply