POST
|
Awesome, I was able to concatenate everything the way I wanted and parse out the things I didn’t. Thanks for the pointers, Dan. This workflow will save me a ton of time. Cheers, Sergio
... View more
08-03-2016
04:27 PM
|
0
|
1
|
765
|
POST
|
Thanks for the quick response. I think this is where the problem is - the section you called out is where I am trying to iterate through the folder where the PDFs are to fill in the match table. Say I have a PDF file named "CSF001 - As-Built". I would want the FAC_ID column to only take in the "CSF001" and get rid of the rest. Then, for the Attachment column, I would want the path name where the file is and the file name at the end so: "C:\PDF_Folder\CSF001 - As-Built.pdf" Then iterate through all 198 files and do the above ^ The table would look like this FAC_ID ATTACHMENT CSF001 C:\PDF_Folder\CSF001 - As-Built.pdf CSF002 C:\PDF_Folder\CSF002 - As-Built.pdf
... View more
08-03-2016
03:08 PM
|
0
|
3
|
765
|
POST
|
I am using ArcGIS Pro. I have a folder with 198 separate PDF files that I want to link to a feature class (input the pathname into the field. I have tried creating a Match Table (and enabled the Add Attachments Tool) - the result was a Table with two columns: 1) FAC_ID 2) ATTACHMENT I am able to fill the attachment column with the file names and ".pdf" at the end. However, I only want the FAC_ID field entries to be filled with the first 6 characters of the PDF file name. This way I can join the table with the feature class based on the FAC_ID field. Also, I just realized that the end goal is to create hyperlinks from the PDF file names in the attribute table but the attachment field is only taking in the PDF file name and not the pathname. Below is the code I used: import csv import arcpy import os import sys input = r"C:\CSF\CSF.gdb\FeatureClass" inputField = "FAC_ID" matchTable = r"C:\Arcpy Scripts\matchtable.csv" matchField = "FAC_ID" pathField = "Attachments" picFolder = r"C:/PDF_Folder" try: # create a new Match Table csv file writer = csv.writer(open(matchTable, "wt"), delimiter=",") # write a header row (the table will have two columns: ParcelID and Picture) writer.writerow([matchField, pathField]) # iterate through each picture in the directory and write a row to the table for file in os.listdir(picFolder): if str(file).find(".pdf") > -1: writer.writerow([str(file).replace(".pdf", ""), file]) del writer # the input feature class must first be GDB attachments enabled arcpy.EnableAttachments_management(input) # use the match table with the Add Attachments tool arcpy.AddAttachments_management(input, inputField, matchTable, matchField, pathField, picFolder) except Exception as err: print(err.args[0])
... View more
08-03-2016
02:41 PM
|
0
|
5
|
1731
|
POST
|
I know this is an older post but I think your script could help with something similar I was trying to do. I want to be able to use Data Driven Pages to give me a list of features from another layer (point) within each page. Basically, I have a GRID polygon layer with a field called PAGE. PAGE is used for DDP with a range of 1-184. I also have a point layer called TRAFFIC SIGNS that has a field with unique FACILITY_ID numbers that I use for inventory purposes. For each PAGE I want to select all the TRAFFIC SIGNS within the page and write out each traffic sign's FACILITY_ID to a text file. I am new to Python so bare with me and thanks for any advice ahead of time!
... View more
11-20-2015
12:57 PM
|
0
|
1
|
1341
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:25 AM
|