8.3 features

28 views
Skip to first unread message

Sam Brenton

unread,
Nov 5, 2025, 6:51:36 AMNov 5
to pyPreservica
Hi James,

I'm interested in this new API feature that's just been released 

/actions/metadata-csv-edits

Are there plans for it to be added to pyPreservica?

Thanks
Sam 

James Carr

unread,
Nov 5, 2025, 8:49:32 AMNov 5
to pyPreservica
Hi
I have just seen this, maybe i can add the API for it. 

It's fairly easy to re-create in pyPreservica already, you just need to loop over the csv file and extract the asset reference and then either create or update the xml metadata using the columns in the csv file.
The following snippet below will get you half way.


from pyPreservica import *
import csv
import xml.etree.ElementTree

client = EntityAPI()
NS = "http://www.preservica.com/metadata/group/test"


with open('my-metadata.csv', newline='') as csvfile:
    reader = csv.DictReader(csvfile)
    # skip first two rows
    next(reader)
    next(reader)
    for row in reader:
        reference = row['entity ref']
        asset = client.asset(reference)
        metadata = client.metadata_for_entity(asset, NS)
        if metadata is None:
            # add new metadata
            # create xml document data
            vehicle = row['Vehicle']
            client.add_metadata(asset, NS, data)
        else:
            xml_document = xml.etree.ElementTree.fromstring(metadata)
            # update metadata set values on xml_document
            data = xml.etree.ElementTree.tostring(xml_document, encoding='UTF-8', xml_declaration=True).decode("utf-8")
            client.update_metadata(asset, NS, data)




Sam Brenton

unread,
Nov 7, 2025, 5:25:32 AMNov 7
to pyPreservica
Thanks James, I'll look in to this 

Sam

James Carr

unread,
Nov 7, 2025, 6:44:07 AMNov 7
to pyPreservica
The code you need to work with any Group/Form csv spreadsheet downloaded from the newGen interface would look something like:


csv_ingest.py

Sam Brenton

unread,
Nov 7, 2025, 6:46:34 AMNov 7
to pyPreservica
Amazing, thank you for this
Reply all
Reply to author
Forward
0 new messages