Select to view content in your preferred language

Display attributes of 10 different single-row GP output tables on a single page?

383
3
3 weeks ago
Bud
by
Legendary Contributor

I have 10 civil asset FCs: roads, sidewalks, sewers, more (Oracle SDE.ST_GEOMETRY EGDB).

And I have a model that clips the FCs using a subdivision polygon and outputs 10 FGDB standalone tables that have a single row of summarized stats about the assets in that subdivision. I can open the attribute table of each table and get the stats, and then manually enter the numbers into an email to our Finance department for financial reporting purposes.

Instead of opening the attribute table of each output table to get the values, I want a single page of stats that I can send to Finance via a printed PDF or some other method. Click a button, get a single page of stats, and manually send an email. I can't union all the outputs together into a single query/report, because each table/asset type has different fields.

How can I display the attributes of 10 different single-row GP output tables on a single page or screen? For example, an ArcGIS Pro report, a single tab in an Excel spreadsheet, a Portal dashboard, or some other reporting software that can display multiple small reports on a single page.

Frequency: 20 runs per year.

Pro Idea: Output multiple small reports on the same page/screen

0 Kudos
3 Replies
Bud
by
Legendary Contributor

Thoughts about an SQL query approach:

Is it possible to write an ST_GEOMETRY SQL query that could clip line features like roads or sidewalks to a SD polygon?

I assume that's not possible for lines, since ST_Geometry SQL functions are limited, whereas it'd be easy for points. But if it were possible, then I could write ten SQL queries in SQL Developer, do a find-and-replace to change the subdivision ID in each query (or set up an SQL parameter to enter the subdivision number), then hit run to run all 10 queries in a single action. Copy the raw output text to an email.

 

0 Kudos
MErikReedAugusta
MVP Regular Contributor

If you can convert the model to a python script, this should be fairly trivial to do, if I'm understanding your needs correctly.  It would also work if there's a way to write a custom GP Tool and insert it into a model, but I genuinely can't remember if that's possible, since I really don't use Model Builder.

Some broad strokes/pseudocode:

import pathlib

tbls = [list of your 10 tables]
outFile = pathlib.Path(r'Path\To\Save\Output\Results.txt')

with outFile.open('w') as txt:
  # We're essentially producing a tab-separated CSV, so print all of your 
  # desired headings on this first line.  Make sure you don't forget that
  # line break \n at the end!  Since we're printing everything to a single
  # result file, I added a column to the beginning to write which source
  # table that row came from
  txt.write('Source\tColumn1\tColumn2\t...ColumnN\n')
  for tbl in tbls:
    with arcpy.da.SearchCursor(tbl, [fields]) as cursor:
      for row in cursor:
        txt.write(tbl)            # Write the table path to the Source column

        txt.write('\t'.join(map(str, row))) # Spin out all the column values 
                                            # to their respective columns,
                                            # and convert to string on-the-
                                            # fly, so join doesn't crash out. 
        # NOTE: This assumes all tables have the same columns. If not, this 
        # gets a little more complex.

        txt.write('\n')           # Write the newline to move on to the next
                                  # row.

    del cursor # They finally fixed the context managers for cursors, so this
               # line is obsolete as of (I think) Pro 3.7, and can be
               # removed.  Keep it for anything older, though.

 

Another thing you could possibly do (if the schemas are the same between the 10 tables) is to run the Append tool to dogpile all of them into a single table, and then just output that.

 

If the schemas are different between the 10 tables, it might be helpful to see what we're looking at data-wise to figure out the simplest way to lay it all up at once.

------------------------------
M Reed
"The pessimist may be right oftener than the optimist, but the optimist has more fun, and neither can stop the march of events anyhow." — Lazarus Long, in Time Enough for Love, by Robert A. Heinlein

If this post or another helped you out, please consider giving the post(s) a Kudo or marking them as the Solution. ESRI Staff use both of these features to help keep track of posts on these forums.
Bud
by
Legendary Contributor

Thanks! This brings to mind a related Python option:

Run a python script that consumes the 10 tables and outputs the results in a big blob of text in the python window that I could copy to an email. Not a very elegant solution; maybe a last resort.

0 Kudos