예제 #1
0
def getFile(iName, dataName):
    instanceURL = "https://" + iName + ".akvolumen.org/api/"
    dashboards = Flow.getData(instanceURL + 'library', token)
    datasets = pd.DataFrame(dashboards['datasets'])
    datasets['api'] = datasets['id'].apply(
        lambda x: instanceURL + 'datasets/' + x)
    dataPath = list(datasets.loc[datasets['name'] == dataName]['api'])[0]
    data = Flow.getData(dataPath, token)
    columns = list(pd.DataFrame(data['columns'])['title'])
    rows = pd.DataFrame(data['rows'], columns=columns)
    downloadName = iName + '_' + dataName + '.csv'
    downloadName = downloadName.replace(' ', '_')
    dir_path = os.path.dirname(os.path.realpath(__file__))
    rows.to_csv(downloadName)
    print("Downloaded to" + dir_path + '/' + downloadName)
예제 #2
0
def getList(iName):
    instanceURL = "https://" + iName + ".akvolumen.org/api/"
    dashboards = Flow.getData(instanceURL + 'library', token)
    datasets = pd.DataFrame(dashboards['datasets'])
    datasets['api'] = datasets['id'].apply(
        lambda x: instanceURL + 'datasets/' + x)
    dataName = list(datasets['name'])
    return dataName
예제 #3
0
def getAll(url):
    data = Flow.getData(url, Flow.getToken())
    formInstances = data.get('formInstances')
    for dataPoint in formInstances:
        dataPoints.append(dataPoint)
    try:
        print(
            checkTime(time.time()) + ' GET DATA FROM[' + INSTANCE + "," +
            url.split("?")[1].replace("&", ",") + ']')
        url = data.get('nextPageUrl')
        getAll(url)
    except:
        print(checkTime(time.time()) + ' DOWNLOAD COMPLETE')
        return "done"
예제 #4
0
def getList():
    token = Flow.getToken()
    dashboards = Flow.getData(lumenInstance + '/api/library', token)
    ds = pd.DataFrame(dashboards['datasets'])
    return ds.to_dict('records')
예제 #5
0
    data = Flow.getData(url, Flow.getToken())
    formInstances = data.get('formInstances')
    for dataPoint in formInstances:
        dataPoints.append(dataPoint)
    try:
        print(
            checkTime(time.time()) + ' GET DATA FROM[' + INSTANCE + "," +
            url.split("?")[1].replace("&", ",") + ']')
        url = data.get('nextPageUrl')
        getAll(url)
    except:
        print(checkTime(time.time()) + ' DOWNLOAD COMPLETE')
        return "done"


apiData = Flow.getData(surveyURI, Flow.getToken()).get("forms")
questions = lambda x: [{
    'id': a['id'],
    'name': a['name'],
    'questions': details(a['questions'])
} for a in x]
details = lambda x: [{
    'id': a['id'],
    'name': a['name'].replace(' ', '_'),
    'type': a['type'],
    'code': a['variableName']
} for a in x]
meta = questions(apiData[0]['questionGroups'])
mt = pd.DataFrame(meta)
groupID = mt['id'][0]
metadata = mt['questions'][0]
예제 #6
0
def getResponse(url,rtype):
    if rtype == "post":
        response = Flow.postData(url, token)
    else:
        response = Flow.getData(url, token)
    return response