Created
October 5, 2018 15:34
-
-
Save adammcmaster/1317843ab578c7e43f35f4de1bb52eec to your computer and use it in GitHub Desktop.
Removing whitespace from existing subject metadata
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from panoptes_client import Panoptes, Project | |
Panoptes.connect( | |
username='astopy', | |
password='', | |
admin=True, | |
) | |
processed = 0 | |
project = Project.find(slug='') | |
for subject_set in project.links.subject_sets: | |
print('\rProcessing set "{}"'.format(subject_set.display_name)) | |
for subject in subject_set.subjects: | |
new_metadata = {} | |
for key, value in subject.metadata.items(): | |
new_metadata[key.strip()] = value | |
subject.metadata.clear() | |
subject.metadata.update(new_metadata) | |
subject.save() | |
processed += 1 | |
print('\rProcessed: {}'.format(processed), end='') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment