I am attempting to take a SHAPEFILE, create separate shapefiles based on specific attributes via split by attributes, adding the separate shapefiles to the map and exporting them to PDF. I am stuck on the last part : adding the shapefiles to the map and exporting them. This is the code that I am using to do this:

workspace = r"C:\Data\NPS"
aprx = arcpy.mp.ArcGISProject(r"C:\Data\NPS\NPSProjTest.aprx")
map = aprx.listMaps()[0]
for lyt in aprx.listLayouts("*"):
    lyt.exportToPDF(r"C:\Data\NPS\NPS.pdf", resolution = 300)

I am getting this error code in return:

File "C:\Users\kimve\AppData\Local\Programs\ArcGIS\Pro\Resources\ArcPy\arcpy\_mp.py", line 1771, in addDataFromPath return convertArcObjectToPythonObject(self._arc_object.addDataFromPath(*gp_fixargs((data_path,), True)))


Any suggestions? I am not sure what I am doing wrong.

1 Answer 1


The addDataFromPath() method of the Map class expects a path to a dataset like a shapefile rather than a path to a workspace like a folder that contains a shapefile.

You are currently providing the latter.

  • Is there another method that I can use to add data from a folder?
    – debugman
    May 5, 2020 at 3:03
  • I'd write some ArcPy code to do that using one or more of the List functions to iterate what it finds. Try that and if you get stuck present where you are stuck as a code snippet in a new question.
    – PolyGeo
    May 5, 2020 at 3:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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