-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexport_report.py
More file actions
49 lines (41 loc) · 1.33 KB
/
Copy pathexport_report.py
File metadata and controls
49 lines (41 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
"""
#####################################################################
## ##
## EXPORT WITH JSON FORMAT AND WRITE TO FILE ##
## ##
#####################################################################
"""
import requests
data = {
'token': ['api_token_here'],
'content': 'report',
'report_id': ['report_id'],
'format': 'json',
'returnFormat': 'json'
}
r = requests.post(['api_url_here'], data)
print(r.text)
with open('report.json', 'w') as file:
file.write(r.text)
"""
#####################################################################
## ##
## EXPORT WITH CSV FORMAT AND WRITE TO FILE ##
## ##
#####################################################################
"""
import requests
import pandas as pd
from io import StringIO
data = {
'token': ['api_token_here'],
'content': 'report',
'report_id': ['report_id'],
'format': 'csv',
'returnFormat': 'csv'
}
r = requests.post(['api_url_here'], data)
df = pd.read_csv(StringIO(r.text))
print(df)
with open('report.csv', 'w') as file:
file.write(r.text)