Skip to content

Commit 08356d3

Browse files
author
ehanson8
committed
Script updates
1 parent 7af24e4 commit 08356d3

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

getPropertiesFromAgentsPeopleCSV.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,17 @@
1010
auth = requests.post(baseURL + '/users/'+user+'/login?password='+password).json()
1111
session = auth["session"]
1212
headers = {'X-ArchivesSpace-Session':session, 'Content_Type':'application/json'}
13+
print 'authenticated'
1314

1415
endpoint = '/agents/people'
1516
arguments = '?page=1&page_size=3000'
1617
output = requests.get(baseURL + endpoint + arguments, headers=headers).json()
18+
records = output['results']
19+
1720
f=csv.writer(open('asResults.csv', 'wb'))
18-
f.writerow(['uri']+['sort_name']+['authority_id']+['names'])
19-
for i in range (0, len (output['results'])):
20-
f.writerow([json.dumps(output['results'][i]['uri']).replace('"','')]+[json.dumps(output['results'][i]['names'][0]['sort_name'], ensure_ascii=False).encode('utf-8').replace('"','')]+[json.dumps(output['results'][i]['names'][0].get('authority_id', '')).replace('"','')]+[json.dumps(output['results'][i]['names'], ensure_ascii=False).encode('utf8')])
21+
f.writerow(['uri']+['sort_name']+['authority_id'])
22+
for i in range (0, len (records)):
23+
uri = records[i]['uri']
24+
sort_name = records[i]['names'][0]['sort_name'].encode('utf-8')
25+
authority_id = records[i]['names'][0].get('authority_id', '')
26+
f.writerow([uri]+[sort_name]+[authority_id])

0 commit comments

Comments
 (0)