-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexport_users.py
More file actions
48 lines (39 loc) · 1.27 KB
/
Copy pathexport_users.py
File metadata and controls
48 lines (39 loc) · 1.27 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
"""
#####################################################################
## ##
## EXPORT WITH JSON FORMAT AND WRITE TO FILE ##
## ##
#####################################################################
"""
import requests
data = {
'token': ['api_token_here'],
'content': 'user',
'format': 'json',
'returnFormat': 'json'
}
r = requests.post(['api_url_here'], data)
print(r.text)
with open('users.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': 'user',
'format': 'json',
'returnFormat': 'json'
}
r = requests.post(['api_url_here'], data)
df = pd.read_csv(StringIO(r.text))
print(df)
with open('users.csv', 'w') as file:
file.write(r.text)