I have a script to export DDP extents to tif and when I change
arcpy.mapping.ExportToTIFF(mxd,"tests\BA\BA10k_" + str(ddp.pageRow.PageName) + ".tif",df,9306,9306*ar,1800,True)
to
arcpy.mapping.ExportToTIFF(mxd,"tests\BA10円k\BA10k_" + str(ddp.pageRow.PageName) + ".tif",df,9306,9306*ar,1800,True)
--added "10k" to the directory I get
Exporting page 1 of 760 Traceback (most recent call last): File "P:2012円183円_TownPlanning_Symbology\Working\Raster_Layer_Creation\DDP_GeoTiff_production_BA.py", line 10, in arcpy.mapping.ExportToTIFF(mxd,"tests\BA10円k\BA10k_" + str(ddp.pageRow.PageName) + ".tif",df,9306,9306*ar,1800,True) File "C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\utils.py", line 181, in fn_ return fn(*args, **kw) File "C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\mapping.py", line 1373, in ExportToTIFF layout.exportToTIFF(*args) AttributeError: DataFrameObject: Error in executing ExportToTIFF
Any ideas on why?
1 Answer 1
\
is an escape character in Python.
You will need to either:
- Escape each
\
with another\
- Put an
r
before the opening quote to denote it as a raw string - Change each
\
to a/
Your symptom of seeing that it seemed to "work without the '\' except if a number was the first character of the directory name" is probably because they weren't valid escape sequences and it was falling back to the literal interpretation. 0円
, 1円
, 2円
.. 7円
, are octal numbers which are translated into ASCII characters, thus mangling your pathnames. More info here: http://docs.python.org/reference/lexical_analysis.html#string-literals