0

I'm trying to customize a data driven page looping statement workflow and want to set a better filename to the final export. Currently the file name uses the page index (pgIndex), but I would like it to use a specific field in the attribute table.

Here is my file naming looping statement:

for pgIndex in range(1, tempDDP.pageCount + 1, 1):
 # Create a name for pdf file 
 temp_filename = r"C:\Desktop\Test\temp_pdfs\MB_" + \
 str(pgIndex) + ".pdf"
 if os.path.exists(temp_filename):
 os.remove(temp_filename)

Any idea how I can get the result I want? I know this is possible if you use the built in export tool for arc 10, but I need more functionality, and therefore a customized script.

asked Sep 4, 2012 at 14:42
2
  • FWIW, more readable as: for i in range(tempDDP.pageCount): label = str(i + 1) Commented Sep 4, 2012 at 15:02
  • Thanks sgillies! Any idea how to change the file naming portion of the script to use a specific value in the attribute table and not the page index? Commented Sep 4, 2012 at 15:14

1 Answer 1

1

Okay, I finally figured out a method using pageRow.FIELDNAME

for i in range(1, tempDDP.pageCount + 1, 1):
 # Create a name for each pdf file
 tempMap.dataDrivenPages.currentPageID = i
 pageName = tempMap.dataDrivenPages.pageRow.Name
 temp_filename = r"C:\Desktop\Test\temp_pdfs\MB_" + \
 str(i) + pageName + ".pdf"
answered Sep 4, 2012 at 16:07
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.