Skip to content

Instantly share code, notes, and snippets.

@tom-montgomery
Created January 15, 2019 16:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tom-montgomery/0af2bd7d3f584039101ca39b9c69a78f to your computer and use it in GitHub Desktop.
Save tom-montgomery/0af2bd7d3f584039101ca39b9c69a78f to your computer and use it in GitHub Desktop.
if update is False:
# figure out next doi suffix to use if new
department_dois = doi_assets.loc[doi_assets['department'] == metadata['department'].item()]
if len(department_dois) != 0:
# add 1 to highest suffix value and use zfill to pad w/zeros to 6 chars
doi_suffix = str((department_dois['doi_suffix'].max()+1)).zfill(6)
else:
# new doi for dept, start at 000001
doi_suffix = str(1).zfill(6)
# zfill dept prefix to 3 chars
doi = '10.26000/{}.{}'.format(str(dept_prefix.index[0]).zfill(3), doi_suffix)
else:
# find existing doi for update
doi = doi_assets.loc[doi_assets['socrata_4x4'] == socrata_4x4]['doi'].item()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment