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.

  • 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
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"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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