This can definitely be done in Python, but you will have to learn a lot!
Here are a few bits to get you started:
- SearchCursor (10.0), da.SearchCursor (10.2) allows you to iterate through tables and get values. You could store the values (date, reading) within lists in a Python dictionary by meter number.
- Python datetime module (inbuilt) will be helpful for working with dates.
- Matplotlib allows you to plot things from Python.
I don't know how to make PDFs from Python, but I have no doubt whatsoever that it is possible...
I would suggest you start playing around with matplotlib, datetime and searchcursors first, once you are familiar with them, start to think about the data structure that you will use to get the information from the searchcursor, analyse the monthly peak, and pass the result to matplotlib. Happy to help if you have more specific queries!
Stacy-
Thank you for the ideas. I have playing around with the SearchCursor in Python and so far all I am getting it to do is to "Print" to the screen. What else would I have to do to extract this data out?
FeatClassArray = [] fc = r"H:\Documents\ArcGIS\Default.gdb\MyFeatureClass" fields = [f.name for f in arcpy.ListFields(fc)] with arcpy.da.SearchCursor(fc, fields) as cursor: for row in cursor: FeatClassArray.append(row) df = DataFrame(FeatClassArray) #now use the df with matplotlib functionality to build your plots/graphs
Having a hard time getting multiple fields to show up.
I have about (4) fields that I need to show:
TWACs_NUMBER
PERIOD_ENDS
KWH_USAGE
KW_DEMAND
So Far - I can get the "TWACs_NUMBER to "print" to the screen - but I need all of these fields to "print" so I can sort them by TWACs NUMBER
I think I should include an example of the data that I am using to better explain what I am trying to accomplish
Attached: Example.xlsx
This is also in a File Geodatabase as a Geodatabase Table
This table is composed of around 9500 meter records (METER NUMBER)
1) Go through the table and find METER NUMBER record with the billing period, KWH and KW Demand rows attached.
2) Extract/export/select a unique METER NUMBER with the data attached (billing period, KWH and KW Demand)
3) Take the data and build a graph showing the Billing Period along the "X" Axis, KWH and KW Demand along the "Y" Axis
4) Export the graph to a .PDF with the METER NUMBER as the file name
From there I can use the Attachments Geoprocessing tool to take the .PDF and attach it to the Meter Location in the .MXD
Long Term Goal is to create a One-Touch custom Button to select a specific METER NUMBER to create a graph described above and automatically create a .PDF.
I know this sounds like a huge project - and want to learn how to build it piece by piece to eventually accomplish the Long Term Goal.
Thanks for your help in advanced
import arcpy from arcpy import env env.overwriteOutput = 1 env.workspace = r"C:\temp\python\test.gdb" table = "Meters" arcpy.TableSelect_analysis(table, r"in_memory\table_sel", "METER_NUMBER = " + arcpy.GetParameterAsText(0)) out_graph_name = arcpy.GetParameterAsText(0) out_graph_pdf = r"C:\Temp\python\Userdata" + "\\" + arcpy.GetParameterAsText(0) + ".pdf" input_template = r"C:\Temp\Python\UserData\KW Demand.grf" #grf file previously saved input_data = r"in_memory\table_sel" # Create the graph graph = arcpy.Graph() # Add a vertical bar series to the graph graph.addSeriesBarVertical(input_data, "KW_DEMAND") # Specify the title of the left axis graph.graphAxis[0].title = "KW Demand" # Specify the title of the bottom axis graph.graphAxis[2].title = "Meter Number" # Specify the title of the Graph graph.graphPropsGeneral.title = "KW Demand by Meter" # Output a graph, which is created in-memory arcpy.MakeGraph_management(input_template, graph, out_graph_name) # Save the graph as an image arcpy.SaveGraph_management(out_graph_name, out_graph_pdf, "MAINTAIN_ASPECT_RATIO", 600, 375)