Skip to content

Instantly share code, notes, and snippets.

@greglinch
Last active December 21, 2015 11:39
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 greglinch/6300824 to your computer and use it in GitHub Desktop.
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
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