Solved! Go to Solution.
Attached is a zip file with an example. Try the following:
1. Extract the zip file to your C:\Temp directory
2. Open ArcMap
3. Under C:\Temp, expand the Data.gdb > Graph toolbox > double-click on the Script
4. Specify a meter number, i.e. 8151830
5. Click OK to execute the tool
Within your C:\Temp directory you should have a graph as a PDF. Is this what you are looking for?
Jake-
This is a great start - but it doesn't seem to be working according to your instructions. Is it open in ArcMap or ArcCatalog? - Also I dont see a place that asks me to type in a meter number
Okay - what is not working here?## extract unique records from a gdb table and make mulitple tables for ## graphing import arcpy, os arcpy.env.overwriteOutput = True table = "C:\MEWCo GIS System\Electric System\MEWCo_Electric_Model-LOCAL.gdb\billing" fields = "BILLING_PERIOD";"METER_NUMBER";"KWH";"KW_DEMAND" # empty list to store unique meter numbers meterNumbers = [] # use a search cursor to extract the unique numbers with arcpy.SearchCursor(table,fields) as cursor: for row in cursor: if not row[1] in meterNumbers: meterNumbers.append(row[1])
This is the error I'm getting:
Traceback (most recent call last):
File "Z:\Operations\Maps and Records\GeoDatabase\MEWCO GIS System\Python Scripts\SearchCursorExample.py", line 16, in <module>
with arcpy.SearchCursor(table,fields) as cursor:
File "C:\Program Files\ArcGIS\Desktop10.0\arcpy\arcpy\__init__.py", line 820, in SearchCursor
return gp.searchCursor(*args)
File "C:\Program Files\ArcGIS\Desktop10.0\arcpy\arcpy\geoprocessing\_base.py", line 357, in searchCursor
self._gp.SearchCursor(*gp_fixargs(args)))
IOError: "C:\MEWCo GIS System\Electric System\MEWCo_Electric_Model-LOCAL.gdbilling" does not exist
This is an error I get back:
Traceback (most recent call last):
File "C:\temp\Script1.py", line 8, in <module>
arcpy.TableSelect_analysis(table, r"in_memory\table_sel", "METER_NUMBER = " + arcpy.GetParameterAsText(0))
File "C:\Program Files\ArcGIS\Desktop10.0\arcpy\arcpy\analysis.py", line 153, in TableSelect
raise e
ExecuteError: ERROR 999999: Error executing function.
An invalid SQL statement was used.
An invalid SQL statement was used. [Meters]
An invalid SQL statement was used. [SELECT * FROM Meters WHERE METER_NUMBER = ]
Failed to execute (TableSelect).
arcpy.TableSelect_analysis(table, r"in_memory\table_sel", "METER_NUMBER = " + arcpy.GetParameterAsText(0))
arcpy.TableSelect_analysis(table, r"in_memory\table_sel", '"METER_NUMBER"' + " = " + arcpy.GetParameterAsText(0))
arcpy.AddFieldDelimiters(table,"METER_NUMBER")
## extract unique records from a gdb table and make mulitple tables for ## graphing import arcpy, os arcpy.env.overwriteOutput = True table = r'H:\Python\test.gdb\billing' fields = ['BILLING_PERIOD','METER_NUMBER','KWH','KW_DEMAND'] # empty list to store unique meter numbers meterNumbers = [] # use a search cursor to extract the unique numbers with arcpy.da.SearchCursor(table,fields) as cursor: for row in cursor: if not row[1] in meterNumbers: meterNumbers.append(row[1]) # for each unique cursor make a table view using the billing number for # the selection for meter in meterNumbers: ## omit the quotes if you table stores the meter number as a number not a string expression = arcpy.AddFieldDelimiters(table,'METER_NUMBER') + " = " + "'" + meter + "'" arcpy.MakeTableView_management(table,"CurrentMeter",expression) # copy the rows to a permanent table in the same location outTable = os.path.join(os.path.dirname(table),("meter_" + meter)) arcpy.CopyRows_management("CurrentMeter",outTable) ## at this point can use the graphing options to generate the graphs and save ## unfortunately don't have the answer yet for this
This is what I see