3

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?

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Oct 22, 2012 at 0:50
0

1 Answer 1

11

\ 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

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
answered Oct 22, 2012 at 0:56
0

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.