Last active
December 21, 2015 11:39
-
-
Save greglinch/6300824 to your computer and use it in GitHub Desktop.
This Python script uses Ben Welsh's python-documentcloud API wrapper (http://datadesk.github.io/python-documentcloud) to delete every document in a specific DocumentCloud.org project. To use, enter in command: line $ pip install python-documentcloud. To execute, type: $ python ./doccloud_delete_docs_in_project.py
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 documentcloud import DocumentCloud | |
""" | |
Delete each document in the specified project | |
""" | |
# define your variables | |
username = "USERNAME_HERE" | |
password = "PASSWORD_HERE" | |
project_title = "PROJECT_TITLE_HERE" | |
# create a client with DocumentCloud.org | |
client = DocumentCloud(username, password) | |
# assign the project to a project object | |
proj_obj = client.projects.get_by_title(project_title) | |
# assign the document ids to an docs object | |
docs = proj_obj.document_ids | |
for doc in docs: | |
obj = client.documents.get(doc) | |
print obj | |
print "deleted" + "\n" | |
obj.delete() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment