<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Get mapx Data Source Properties In Python in ArcGIS Enterprise Questions</title>
    <link>https://community.esri.com/t5/arcgis-enterprise-questions/get-mapx-data-source-properties-in-python/m-p/1056898#M30155</link>
    <description>&lt;P&gt;I am trying to write a python script that will crawl through the arcgisinput folder/subfolders for all the MXD, and .mapx documents that have been published to ArcGIS Enterprise. I would like to get all the Data Source properties (MapDocument Name, Feature Class, Database, Owner etc). I have a working script for MXD's but cannot incorporate the .mapx file.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help with this would be greatly appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 11 May 2021 21:19:24 GMT</pubDate>
    <dc:creator>StevenCross</dc:creator>
    <dc:date>2021-05-11T21:19:24Z</dc:date>
    <item>
      <title>Get mapx Data Source Properties In Python</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/get-mapx-data-source-properties-in-python/m-p/1056898#M30155</link>
      <description>&lt;P&gt;I am trying to write a python script that will crawl through the arcgisinput folder/subfolders for all the MXD, and .mapx documents that have been published to ArcGIS Enterprise. I would like to get all the Data Source properties (MapDocument Name, Feature Class, Database, Owner etc). I have a working script for MXD's but cannot incorporate the .mapx file.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help with this would be greatly appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 May 2021 21:19:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/get-mapx-data-source-properties-in-python/m-p/1056898#M30155</guid>
      <dc:creator>StevenCross</dc:creator>
      <dc:date>2021-05-11T21:19:24Z</dc:date>
    </item>
    <item>
      <title>Re: Get mapx Data Source Properties In Python</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/get-mapx-data-source-properties-in-python/m-p/1056941#M30156</link>
      <description>&lt;P&gt;I've not used mapx files yet. I just created one and looked at it.&lt;/P&gt;&lt;P&gt;A mapx file is just a text file containing JSON data and they are not even minified so you can just list them out. Looks like all the information you want is in the section "layerDefinitions".&lt;/P&gt;&lt;P&gt;Generally I load JSON files into Python objects and then examine them in the Visual Studio Code debugger and pull them apart with Python until I find the bits that I need.&lt;/P&gt;&lt;P&gt;Does that make sense to you or do you want a snippet of Python?&lt;/P&gt;&lt;P&gt;Maybe there is some cool Python API thing, I'm going to look because I want the rich Esri learning experience but generally I'd just hack the JSON personally.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 May 2021 23:26:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/get-mapx-data-source-properties-in-python/m-p/1056941#M30156</guid>
      <dc:creator>Brian_Wilson</dc:creator>
      <dc:date>2021-05-11T23:26:19Z</dc:date>
    </item>
    <item>
      <title>Re: Get mapx Data Source Properties In Python</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/get-mapx-data-source-properties-in-python/m-p/1057190#M30165</link>
      <description>&lt;P&gt;I did a brief search of arcgis py but did not see anything helpful, so I wrote a few lines of plain old Python (no Esri modules). Here is the code,&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;"""
Open a mapx file and find the Data Source properties 
"""
import json
file = "k:/e911/e911 map.mapx"
with open(file, 'r') as fp:
    mapx = json.load(fp)

map_name = mapx['mapDefinition']['name']
layers = mapx['layerDefinitions']
for layer in layers: 
    print("-"*72)
    print("type: %s name: \"%s\"" % (layer['type'], layer['name']))
    try:
        data = layer['featureTable']['dataConnection']
        print("dataset: %s" % data['dataset'])
        print("%s\t%s" % (data['workspaceFactory'], data['workspaceConnectionString']))
    except:
        # Uncomment this line for debugging, so you can see what did not 
        # look like a data source. For example, group layers show up here.
        print(json.dumps(layer, indent=2))
        pass
    print()&lt;/LI-CODE&gt;&lt;DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 12 May 2021 15:54:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/get-mapx-data-source-properties-in-python/m-p/1057190#M30165</guid>
      <dc:creator>Brian_Wilson</dc:creator>
      <dc:date>2021-05-12T15:54:33Z</dc:date>
    </item>
  </channel>
</rss>

