I have a file with the following properties where I can retrieve created and modified dates by using pathlib (st_ctime, st_mtime) easily.
But I want to get the date displayed in the Details section of the same property tab, shown in the red box:
How can I do that in python preferably by using inbuilt packages?
note that this only works for new style xlsx files
>>> from xml.etree import ElementTree
>>> import zipfile
>>> xls_zip = zipfile.ZipFile("example.xlsx")
>>> xml_contents = xls_zip.read("docProps/core.xml")
>>> et = ElementTree.fromstring(xml_contents)
>>> created = et.find('dcterms:created',{"dcterms":"http://purl.org/dc/terms/"}).text
>>> modified = et.find('dcterms:modified',{"dcterms":"http://purl.org/dc/terms/"}).text
>>> print("C:",created)
C: 2020-04-24T17:46:16Z
>>> print("M:",modified)
M: 2020-04-24T17:46:16Z
this just opens the xlsx file as a zipfile (you can rename the file to end with zip and just open it with the windows explorer unzip)
then it gets the "file" that contains the metadataxml
then it extracts (from the proper namespace) the keys that correspond to those 2 values