"last Modified By" (user Name, Not Time) Attribute For Xlsx Using Python
I need to be able to view the 'last modified by' attribute for xlsx files using Python. I've been able to do for docx files, and was hoping that the architecture would be similar e
Solution 1:
For .xlsx
files, you can use this (set filename
to the name of your .xlsx
file):
import xml.etree.ElementTree
import xml.etree.cElementTree as ET
import zipfile
corePropNS = '{http://schemas.openxmlformats.org/package/2006/metadata/core-properties}'
zf = zipfile.ZipFile(filename, 'r')
part = zf.open('docProps/core.xml', 'r')
tree = ET.XML(part.read())
lastModifiedBy = tree.find(corePropNS+'lastModifiedBy').text
print(lastModifiedBy)
I haven't tested it, but I'd expect the same code to work for other OOXML files too (e.g. .docx
)
Solution 2:
Sorry I'm late, but here is what I got to work.
importxlrdwb= xlrd.open_workbook(a_file)
worksheet = wb.sheet_by_index(0)
mod_by = worksheet.book.props['last_modified_by']
Solution 3:
import os
filename = "C:\\test.xlsx"
statsbuf = os.stat(filename)
print"modified:",statsbuf.st_mtime
f = os.path.getmtime('C:\\test.xlsx')
print f
since the beginning
Post a Comment for ""last Modified By" (user Name, Not Time) Attribute For Xlsx Using Python"