@@ -0,0 +1,1217 @@
+#!/usr/bin/env python%0A%0Aimport httplib%0Aimport urllib%0Aimport time%0Aimport csv%0Aimport os%0Aimport elasticsearch%0A%0A# Set the token in the environment. (Is this a good idea?)%0A# E.g., export GH_API_TOKEN=your_token%0Atoken = os.env.get('GH_API_TOKEN')%0A%0Aauth_header = 'x-oauth-basic'%0Aapi_host = 'api.github.com'%0Auser_agent_header = 'User-Agent'%0Auser_agent = 'Glue Mule/Haiku'%0A%0Aparams = urllib.urlencode(%7B'foo':'bar'%7D)%0Aheaders = %7Bauth_header : token, user_agent_header : user_agent%7D%0A%0Aconn = httplib.HTTPSConnection(api_host,443)%0A%0A%0Adef read_csv(f='./gh_gov_orgs.csv'):%0A%09with open(f, 'r') as _csv:%0A%09%09reader = csv.reader(_csv)%0A%09%09for row in reader:%0A%09%09%09_org = row%5B1%5D%0A%09%09%09print get_org (org)%0A%09%09%09write_to_es( org )%0A%09%09%09time.sleep(.05)%0A%0A%0A%0Adef get_org(org):%0A    _resource = %22/orgs/%22 + org %0A    print _resource%0A    conn.request(%22GET%22, _resource, None, headers)%0A    response = conn.getresponse()%0A    json = response.read()%0A    return json%0A%0A%0A%0A%0A%0A# Should use the Elastic Search Python API%0Aes_host = 'localhost'%0Aes_port = 9200%0Aesparams = urllib.urlencode(%7B'':''%7D)%0Aesconn = httplib.HTTPSConnection(es_host,es_port)%0A%0A%0Adef write_to_es():%0A%09_resource = 'gluemule/org/'%0A%09pass%0A# ----------------------------%0A%0Aread_csv()%0A%0Aconn.close()%0A%0A#get_org('cfpb')%0A%0A%0A

Add script for ES import