Select to view content in your preferred language

CCTV Manager Solution - modelbuilder iteration fails when using inline variable substitution

1151
5
03-03-2021 11:48 AM
GISUser74305830
Regular Contributor

I am using the CCTV Manager Solution. I am trying to create a model to iterate over a series of folders and run the Import Access Tables script on the MDB file within. I am using inline variable substitution to construct the Access database file path. The script will not accept what I try to pass into it.

The Access database parameter is set as a File type. It works if I hardcode the Access database. But when I try to construct the Access database path using inline variable substitution, it errors out and won't accept that.

  • The MDB file is located here: 
    • C:\CCTV_Inspections\2020_05_11\2020_05_11_PACP _ LACP _ MACP 6.0.mdb
  • The iterator produces the following output:
    • Folder - i.e. C:\CCTV_Inspections\2020_05_11
    • Folder Name - i.e. 2020_05_11
  • I've constructed the Access database name using inline variable substitution:
    • %Folder%\%Folder Name%_PACP _ LACP _ MACP 6.0.mdb
    • When translated, it matches exactly the MDB file path

Here is my model:

GISUser74305830_3-1614800759051.png

 

 

0 Kudos
5 Replies
DanPatterson
MVP Esteemed Contributor

It doesn't produce a valid name

 

folder = "C:\CCTV_Inspections\2020_05_11"

folder_name = "2020_05_11"

txt = "_PACP _ LACP _ MACP 6.0.mdb"

folder + folder_name + txt

 'C:\\CCTV_Inspections\x820_05_112020_05_11_PACP _ LACP _ MACP 6.0.mdb'

Raw encoding does

folder = r"C:\CCTV_Inspections\2020_05_11"

folder_name = r"2020_05_11"

txt = r"_PACP _ LACP _ MACP 6.0.mdb"

folder + folder_name + txt

'C:\\CCTV_Inspections\\2020_05_112020_05_11_PACP _ LACP _ MACP 6.0.mdb'

And never use folders that begin with numbers, a, r, t, and a bunch of other characters too many to list

 


... sort of retired...
0 Kudos
GISUser74305830
Regular Contributor

what am i doing wrong? 

0 Kudos
DanPatterson
MVP Esteemed Contributor

Your paths aren't able to make a valid filepath when concatenated together, hence my example of "raw encoding" by adding the little 'r' to the front of each element.  


... sort of retired...
0 Kudos
GISUser74305830
Regular Contributor

Can you raw encode in Modelbuilder? 

0 Kudos
DanPatterson
MVP Esteemed Contributor

I use python not modelbuilder, but I suspect this is why this tool exists for modelbuilder

Parse Path (ModelBuilder)—ArcGIS Pro | Documentation

but I haven't used it


... sort of retired...
0 Kudos