I'm working on trying to use arcpy to automate the creation of a report, but I'm running into a problem.
>>> arcpy.mapping.ExportReport('2013pp',"C:\reports\2013_Graffiti.rlf","C:\reports\2013_Graffiti_report.pdf")
Runtime error
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "c:\program files\arcgis\desktop10.1\arcpy\arcpy\utils.py", line 181, in fn_
return fn(*args, **kw)
File "c:\program files\arcgis\desktop10.1\arcpy\arcpy\mapping.py", line 506, in ExportReport
assert isinstance(report_source, (MapDocument, TableView, Layer)), str(type(report_source))
AssertionError: <type 'str'>
I'm having trouble deciphering the traceback as it seems to reference a variety of internal python files. In trouble shooting so far, I thought the problem might be that the report_source needs to be a layer file and I was using a .shp so I converted to a .lyr but then I get the error:
Parsing error SyntaxError: invalid syntax (line 1)
In response to the suggestions below, I've tried the following with full paths, but am receiving the same error.
>>> arcpy.mapping.ExportReport('2013pp',r"C:\reports\Graffiti.rlf", r"C:\reports\2013_Graffiti_report.pdf")
Runtime error
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "c:\program files\arcgis\desktop10.1\arcpy\arcpy\utils.py", line 181, in fn_
return fn(*args, **kw)
File "c:\program files\arcgis\desktop10.1\arcpy\arcpy\mapping.py", line 506, in ExportReport
assert isinstance(report_source, (MapDocument, TableView, Layer)), str(type(report_source))
AssertionError: <type 'str'>
When I try Blord's suggestion I get the following:
>>> arcpy.mapping.ExportReport(arcpy.mapping.Layer('2013pp.lyr'),"C:\reports\2013_Graffiti.rlf","C:\reports\2013_Graffiti_report.pdf")
Runtime error
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "c:\program files\arcgis\desktop10.1\arcpy\arcpy\arcobjects\mixins.py", line 389, in __init__
super(LayerMixin, self).__init__(lyrfile)
File "c:\program files\arcgis\desktop10.1\arcpy\arcpy\arcobjects\_base.py", line 47, in __init__
for arg in args))
ValueError: Object: CreateObject Layer invalid data source
>>>
The last part about the invalid data source makes me wonder about whether the shape file is acceptable...it should be given that I am able to manually create a report with it.
As an aside, is this only an arcpy mapping tool, i.e. I can't find it in ModelBuilder or in a toolbox?
I was hoping to try to trouble shoot by creating the tool in ModelBuilder, exporting it and examining the script.