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)
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
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"
def getList(): token = Flow.getToken() dashboards = Flow.getData(lumenInstance + '/api/library', token) ds = pd.DataFrame(dashboards['datasets']) return ds.to_dict('records')
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]
def getResponse(url,rtype): if rtype == "post": response = Flow.postData(url, token) else: response = Flow.getData(url, token) return response