ExportReportingData

Title  Export Reporting Data

Description

Exports tables with domain descriptions to an output geodatabase.

Usage

          
- For optimal read performance, a database connection is recommended.

- For optimal write performance, a mobile geodatabase (sqlite) is recommended for the Output Geodatabase.

- File geodatabases only support a subset of views.

- If you specify the utility network controller dataset, association and controller views will only be created to the input datasets if the target dataset name matches the class name in the source utility network.

- You can target the same target dataset with multiple Input Datasets. This allows you to specify the layers with definition queries or subtype group layers for the Input Datasets and load their records to a single target dataset.

- If the length of the view name exceeds the table name limit, the subtype description will be replaced with its code.

License

Basic

Syntax

ExportReportingData (output_gdb, {datasets}, {output_options}, {controller_dataset}, {field_override})

Parameter Explanation Data Type
output_gdb Dialog Reference

The output geodatabase where the records will be exported.

DEWorkspace
datasets (Optional) Dialog Reference

The datasets to export.

  • Dataset - the dataset to export. Using a layer in a map can improve performance of the execution of the tool and the validation of geoprocessing while populating the tools parameters. If a layer is specified, only the selected records and the layer's visible fields will be exported.
  • Table Name - the name of the table in the Output Geodatabase. If it doesn't exist, it will be created.
  • Include Geometry - For feature classes, this will export the geometry column.

GPValueTable
output_options (Optional) Dialog Reference

Various options that control how the output is created. Create Database Views is only available with an ArcGIS Pro Standard or Advanced license.

  • Load Records - Load the records into target table.
  • Create Database Views - Creates common database views on the exported tables. If the length of the view name exceeds the table name limit, the subtype description will be replaced with its code.
  • Truncate Tables - Truncates tables in the Output Geodatabase before loading records.
  • Load Associations - When exporting a Utility Network, load the association records.
  • Load Subnetwork Controllers - When exporting a Utility Network, load the subnetwork controller records.

GPString
controller_dataset (Optional) Dialog Reference

The Utility Network. When specified, additional options will be available.

GPUtilityNetworkLayer
field_override (Optional) Dialog Reference

A table defining field names and visibility for the subtype views. This parameter is only applicable when "Create Database Views" is checked. The Map Layers to CSV tool in the Map toolset can be used to generate a table in this format from a map. It has the following schema:

  • Dataset - The name of the target table in the output geodatabase.
  • SubtypeCode - The subtype code used in the view definition.
  • FieldName - The name of the field in the dataset.
  • ViewFieldName - The name of the field as it appears in the view.
  • Visible - If the field will be included in view.

GPTableView

Code Samples

ExportReportingData example 1 (stand-alone script)

Exports all the classes from a Utility Network in parallel.

import datetime
import multiprocessing
import os

import arcpy

utility_network = "D:/data/un.sde/UtilityNetwork/Network"
reporting = "D:/data/reporting.sde"
include_geometry = False
schema_options = [
    "CREATE_VIEWS",
]
data_options = [
    "LOAD_RECORDS",
    "TRUNCATE_TABLES",
]
un_options = [
    "UN_ASSOCIATIONS",
    "UN_CONTROLLERS",
]


def gather_sources():
    """All the UN sources"""
    for network in arcpy.Describe(utility_network).domainNetworks:
        for source in network.junctionSources + network.edgeSources:
            if source.utilityNetworkFeatureClassUsageType == "SubnetLine":
                continue
            yield source.name.split(".")[-1]


def export(**kwargs):
    arcpy.udms.ExportReportingData(
        output_gdb=reporting,
        **kwargs,
    )


def export_wrapper(arg):
    return export(**arg[0])


if __name__ == "__main__":
    # (path, output name, geometry)
    gdb = os.path.dirname(os.path.dirname(utility_network))
    paths = [(os.path.join(gdb, s), s, include_geometry) for s in gather_sources()]

    # Create the necessary schema/views in a first pass. This is suggested when running in parallel.
    # If the schema is already defined, this step can be skipped.
    export(datasets=paths, controller_dataset=utility_network, options=schema_options + un_options)

    # Start Associations/Controllers first since this typically is one of the larger tables.
    work = [[dict(controller_dataset=utility_network, output_options=data_options + un_options)]]
    for path in paths:
        work.append([dict(datasets=[path], output_options=data_options)])

    # Spawn 4 subprocesses to divide the work.
    print("Starting", datetime.datetime.now())
    with multiprocessing.Pool(processes=4, maxtasksperchild=1) as pool:
        pool.map(export_wrapper, work, chunksize=1)
    print("Done", datetime.datetime.now())