Last active
August 29, 2015 13:56
-
-
Save grundprinzip/9092944 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
#!/usr/bin/env python | |
import sys | |
import json | |
import base64 | |
import requests | |
import urllib | |
def issuccessful(request): | |
if 200 <= request.status_code and request.status_code <= 299: | |
return True | |
else: | |
return False | |
baseurl = "http://diufpc301:20550" | |
# Get the bleats | |
url = baseurl + "/ngrams2/" + urllib.quote_plus(sys.argv[1]) + "/ngram:cnt" | |
print url | |
request = requests.get(url, headers={"Accept" : "application/json"}) | |
if issuccessful(request) == False: | |
print "Could not get messages from HBase. Text was:\n" + request.text | |
quit() | |
bleats = json.loads(request.text) | |
result = [] | |
for row in bleats['Row']: | |
for cell in row['Cell']: | |
value = base64.b64decode(cell['$']) | |
result.append(value) | |
print result | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment