Exporting Data Driven Pages when Page Name has a new line feature within it.

1560
6
03-06-2013 04:32 PM
KerissaReedy
New Contributor
I have over 400 landholder maps to export, I am wanting to export then as Multiple PDF Files (page name) however the attribute / page name is in the format as follow:
Smith, Ben
Smith, Jenny

DDP will just skip any pages that have a newline character in the Page Name. I can export it by Multiple PDF Files (page index) but i would then only have to rename all the PDFs to the owner names.

Does anyone have a workaround or solution to this problem???
0 Kudos
6 Replies
KamrulKashem
New Contributor III
Hi,

So are you saying in on one record in the attribute table there is actually 2 records? As in a carriage return after every 2nd name? Or just in the name field?


If so, I'd export table to excel, sort out the carriage returns and import back to catalog as a feature.
0 Kudos
DarrenWiens2
MVP Honored Contributor
You can also simplify your page names into a different column. So, your page name would be "Smith" (if that's all the Smiths), or "Smith1", or whatever. Then, display the text for "Smith, Ben Smith, Jerry" in a dynamic text box.
0 Kudos
KerissaReedy
New Contributor
Hi,

So are you saying in on one record in the attribute table there is actually 2 records? As in a carriage return after every 2nd name? Or just in the name field?


If so, I'd export table to excel, sort out the carriage returns and import back to catalog as a feature.


Yes, In some records there is multiple landowners and there is a carriage return after each landowner eq
Ben Smith
Margaret Black
This is the way our Property Database creates the records and I was trying to avoid exporting them out and back in again.
0 Kudos
KerissaReedy
New Contributor
You can also simplify your page names into a different column. So, your page name would be "Smith" (if that's all the Smiths), or "Smith1", or whatever. Then, display the text for "Smith, Ben Smith, Jerry" in a dynamic text box.


Thankyou for your reply. In order to simplify the page names wouldnt DDP require this to be a separate field? or is there a way to pull out the 'Smith' out of the existing Landowners field using a dynamic text box?
0 Kudos
JeffBarrette
Esri Regular Contributor
I think it might be much safer to use another field to manage the DDP sequencing and insert your owner name information as dynamic text.  If you really want to get fancy with parsing and formatting the strings depending on lengths and number of new lines, then that could be accomplished with arcpy.mapping.

Jeff
0 Kudos
GeorgeNewbury
Occasional Contributor
You have options, and from simple to complex:

1. Create a new field within in your index that has the name exactly as you want it to be, use a vb/python field calculation to populate this new field. You'd probably have to pull in the field with the new line characters, split on that, then split on the comma and rearrange it to how you want it to be.

2. Export them with the page number, and then run a renaming script of some sort. I default to python, but you could probably come up with something in another language if you wanted to. You could export the table to an excel file and do your renaming in that. 

Below is code that I used to rename all of my pdfs, basically when I export (I use terrago geopdf more  than the default arcmap pdf) I end up with a single character at the beginning of my name. E.g. if my export name was 'foo', it will export it as '_foo.pdf', and I want to add '_geo' to the end. So the below script takes off the first charcater '_' and adds '_geo' to the end. It runs really quick. You could easily write out a csv file, read that in as a dictionary and then do the renaming. I save the code below as 'rename.py' and just put in the same directory as the pdfs that I'm renaming.

import os, inspect

scriptName = inspect.getfile( inspect.currentframe() )
scriptFolder =  os.path.split(scriptName)[0]

for dirpath, dirnames, filenames in os.walk(scriptFolder):    
    for filename in filenames:
        if filename.endswith(".pdf") and not filename.endswith("_geo.pdf"):
            oldfilename = os.path.join(dirpath, filename)
            newfilename = os.path.join(dirpath, os.path.splitext(filename)[0][1:] + "_geo.pdf")
            print "old: " + oldfilename
            print "\tnew: " + newfilename
            os.rename(oldfilename, newfilename)


3. Write a python script to export a page at a time (through a loop of course), where you take the field that has the names in it and parse it out to how you want it to be. So this would avoid creating another field, but require a little more complexity in terms of writing the export code.

Hope this helps.

George
0 Kudos