Advertisement
Guest User

Untitled

a guest
Nov 5th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. from mstrio import microstrategy
  2. import pandas as pd
  3. import json
  4. from datetime import datetime
  5. from mstrio.api import reports
  6. from mstrio.utils.parsejson import parsejson
  7.  
  8. base_url = "http://192.168.0.17:8080/MicroStrategyLibrary/api"
  9. project_id = "2916035E465E16431D6012B3FF137342"
  10. login = "administrator"
  11. password = ""
  12.  
  13. conn = microstrategy.Connection(base_url, username=str(login), password=str(password), project_name="MicroStrategy Tutorial")
  14. conn.connect()
  15. startTime = datetime.now()
  16. limit_value = 500
  17. response = reports.report_instance(connection=conn, report_id = "4B99AC5E41A66BB229D3ABAFEF812562", offset=0, limit=limit_value)
  18. json_response = response.json()
  19. instance_id_value = json_response['instanceId']
  20. print("Instance retrieved")
  21. pagination = json_response['result']['data']['paging']
  22.  
  23. table_data = [parsejson(response=json_response)]
  24.  
  25. for _offset in range(limit_value, pagination['total'], limit_value):
  26. response = reports.report_instance_id(connection=conn, report_id = "4B99AC5E41A66BB229D3ABAFEF812562", instance_id=instance_id_value, offset=_offset, limit=limit_value)
  27. json_response = response.json()
  28. table_data.append(parsejson(response=json_response))
  29.  
  30. #print(str(json_response['result']['data']['root']['children'][0]['element']['formValues']['DESC']))
  31. instance = pd.concat(table_data)
  32. res_df = pd.DataFrame(instance)
  33. print("CONTENT LOADED ")
  34. print(len(res_df))
  35. print((datetime.now() - startTime))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement