Skip to content

Instantly share code, notes, and snippets.

@djpillen
Last active August 29, 2015 14:21
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 djpillen/b5cbff05be0c9db5d19f to your computer and use it in GitHub Desktop.
Save djpillen/b5cbff05be0c9db5d19f to your computer and use it in GitHub Desktop.
Print Extents from EADs
import lxml
from lxml import etree
import os
from os.path import join
# Enter the path to the folder containing your EADs
path = 'path/to/EADs'
# Check each file in the EAD folder
for filename in os.listdir(path):
tree = etree.parse(join(path, filename))
extents = tree.xpath('//ead/archdesc/did//physdesc/extent') # Check each collection level extent
for e in extents: # Output the contents of each extent
extent = e.text
print 'The extent of ' + filename + ' is: ' + extent
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment