Skip to content

Commit

Permalink
org_code_numbers.get_numbers: Update DataFrame with numbers (iss #32)
Browse files Browse the repository at this point in the history
  • Loading branch information
astrochun committed Jun 12, 2020
1 parent 3f9fe8f commit 5428bf4
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions ReQUIAM/org_code_numbers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

# For database/CSV
import pandas as pd
import numpy as np
from urllib.error import URLError

# For LDAP query
Expand All @@ -19,7 +20,7 @@ def get_numbers(lc, org_url):
"""
Purpose:
Determine number of individuals in each organization code with
Library services
Library privileges
:param lc: LDAPConnection() object
:param org_url: URL that provides CSV
Expand All @@ -29,13 +30,17 @@ def get_numbers(lc, org_url):
try:
df = pd.read_csv(org_url)

print(f"Number of organizational codes : {df.shape[0]}")
n_org_codes = df.shape[0]
print(f"Number of organizational codes : {n_org_codes}")

org_codes = df['Organization Code'].values
for org_code in org_codes:

lib_privilege = np.zeros(n_org_codes)
for org_code, ii in zip(org_codes, range(n_org_codes)):
query = ldap_query.ual_ldap_query(org_code)
members = ldap_query.ldap_search(lc, query)
print(f"{org_code} {len(members)}")
lib_privilege[ii] = ldap_query.ldap_search(lc, query)

df['lib_privilege'] = lib_privilege

except URLError:
print("Unable to retrieve data from URL !")
Expand Down

0 comments on commit 5428bf4

Please sign in to comment.