...
POST to /api/trends/region with master user token.
Populating Parameters Table
Python Script for parsing a parameters.json file (The parameter.json file for GLM is also on this snippet)
https://opensource.ncsa.illinois.edu/bitbucket/snippets/6f31b95bf0834285a21fe0ad62c16e96
To create a parameter.json file from v2/parameters.json remove the variable name and = sign and just have the configuration within []
Populating the Regions Table
Use https://opensource.ncsa.illinois.edu/bitbucket/snippets/e2862e635cbf426988d8c6d4231e151b
and post to /api/trends/region with valid token.
Sample scripts for ingesting the data
Code Block | ||
---|---|---|
| ||
import requests
import csv
import json
import argparse
from requests.auth import HTTPBasicAuth
def main():
URL = 'http://localhost:9000/'
client = requests.session()
user = {
'identifier': 'indiragp@illinois.edu', 'password': 'password'
}
r = requests.post('http://localhost:9000/api/authenticate',
data=json.dumps(user), headers={'Content-Type': 'application/json'})
print(r.status_code)
print(r.headers)
file = "/Users/indiragp/git/seagrant-parsers-py/areas.json"
new_headers = r.headers
new_headers['Content-Encoding'] = "application/json"
with open(file) as f:
data = json.load(f)
k = requests.post('http://localhost:9000/api/trends/region', data=json.dumps(data), headers=new_headers)
print(k.headers)
print(k.status_code)
print(k.json())
if __name__ == "__main__":
main() |