Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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.

share|improve this question
    
FWIW, more readable as: for i in range(tempDDP.pageCount): label = str(i + 1) –  sgillies Sep 4 '12 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? –  Czed Sep 4 '12 at 15:14
add comment

1 Answer 1

up vote 1 down vote accepted

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"
share|improve this answer
    
Please mark this answer as accepted so others can find it. –  Jason Scheirer Sep 4 '12 at 18:34
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.