batch metadata export 9.3.1

3242
4
09-11-2014 02:45 PM
forestknutsen1
MVP Regular Contributor

We need to export all of the metadata for feature data sets and feature classes out of a SDE in FGDC CSDGM XML format without updating it to the new ESRI metadata structure.

 

We have both arcgis 9.3.1 and 10.1. The SDE is 9.3.1.

 

I am looking for the best solution for this problem. My first thought is python; however, my supervisor was unable to implement this because the available tool called updates the metadata to 10.1 (I do not see a way to do it in python for 9.3.1). So maybe vba is the way to go...

 

Please suggest the best approach to this problem.

 

Thanks!

 

Forest

0 Kudos
4 Replies
forestknutsen1
MVP Regular Contributor

So I think I have a solution worked out with python and a mdb. My plan is to copy the datasets and feature class to a mdb database (esri personal database) and then read the metadata directly with pyodbc.

pyodbc - Python ODBC library - Google Project Hosting

This should work fine I believe. I have posted the code for just the metadata export for mdb part. Sorry I do not know what happed to the syntax highting option it is gone on my browser.

# import arcpy

import pyodbc

# set up some constants

MDB = r"C:\python_working\test.mdb"

DRV = '{Microsoft Access Driver (*.mdb)}'

PWD = 'pw'

# connect to db

con = pyodbc.connect('DRIVER={};DBQ={};PWD={}'.format(DRV,MDB,PWD))

cur = con.cursor()

# run a query and get the results

SQL = 'SELECT Documentation FROM GDB_Items;' # your query goes here

rows = cur.execute(SQL).fetchall()

for row in rows:

    temp = row[0]

    if temp is not None:

        file = open('C:/python_working/test.xml', 'w')

        file.write(temp)

        file.close()

    print temp

cur.close()

con.close()

0 Kudos
curtvprice
MVP Esteemed Contributor

>Sorry I do not know what happed to the syntax highting option it is gone on my browser.

You need to open the thread by clicking on the title at the top and then you'll see "Use advanced editor" on the upper right of the edit window.

Posting Code blocks in the new GeoNet

curtvprice
MVP Esteemed Contributor

The XML Transformation tool should work fine dumping the metadata to an XML file directly from your 9.3 geodatabase without trouble.  You need to use the "exact copy of" XSLT file from the Desktop install folder. You could even do this from Model Builder, not even Python!

forestknutsen1
MVP Regular Contributor

Sweet. I have already sorted this one out by exporting the schema and then I made a quick xml parser with python. I think that this should be fine. Looks good in testing.... Thanks for the input it is much appreciated.

0 Kudos