2

I'm running a model to convert .txt files to a table, then join that table with a parcels shapefile, and finally export out that join as a new shapefile.

However, the copy Feature's tool is consistently failing and I am unsure of why.

I am iterating through a folder of .txt files -> making those .txt a Table view to be able to input that into a Table to Table tool. -> Joining that newly created Table with a parcels layer -> then copying those features.

I'm not sure if the error is occurring because the Remove Join is incorrectly placed? Or if my issues are happening earlier in the process.

  • What data type is your output table in the tool Table to Table? Not every data type that is recognized as a table can be written to. – Michael Stimson May 21 '18 at 22:11
  • 1
    Try putting a REMOVE JOIN after you have copied the features, currently your logic is joining to a table already with joins. – Hornbydd May 21 '18 at 22:12
  • Michael Stimson - this question kind of tripped me up, because there is no 'output type' in the Table to Table conversion. I have the Output Table as %name%, but there seems to be no 'data type' being generated. I'll include a picture of the Table to Table tool – Amber May 21 '18 at 22:42
  • I think you need Table-to-Table or Table to Excel, that way you will later need only Excel to Table. @Amber – George Nostradamos May 22 '18 at 17:54
  • @Hornbydd, Thanks for the advice - I'm wondering if this is what my real issue is - however after incorporating it, the process still fails. I'm not sure if I have the remove join in the wrong place? I copied an example I've seen previously on this forum. – Amber May 23 '18 at 17:54
1

Instead of trying to "Copy Features" the joined data to a new shapefile, I would recommend first limiting your selection set with "Select By Attributes", then "Copy Features" just those polygons for features in question. Now, join the tabular data (from the text files) to your newly exported polygons using the "Join Field" tool. Join Field will automatically append the newly joined tabular data to your destination polygon layer, thereby avoiding the Add/Remove Join dependency.

0

I had to complete a similar exercise a while back. If you are comfortable with arcpy, the code below should get you the rest of the way. I think I adopted it from GeoNet.

From your model, it seems you are able to create the tables. If you save your tables after the Table to Table step, this code will take the tables and join them to the parcels shapefile and create new shapefiles.

Main thing is to point to right directories.

import arcpy

arcpy.env.workspace = "C:/folder/tables_folder"

inFc = "C:/folder/parcels.shp"
outDir = "C:/folder/foler2/"

#loop through tables
for table in arcpy.ListTables():
  #Create a temporary new feature layer
  arcpy.MakeFeatureLayer_management(inFc, "parcelLyr")

  #Join table to feature layer; Change table JOIN_FIELD to the right fields
  arcpy.AddJoin_management("parcelLyr", "JOIN_FIELD", table, "JOIN_FIELD")

  #get table name for use in new name of shapefile, drop extension
  tableName = table.split(".")[0]

  #Export joined layer to new feature class
  arcpy.FeatureClassToFeatureClass_conversion("parcelLyr", outDir, tableName)
  • I'm sorry, I am not proficient with python at all and I tried using your script as a guideline and I failed at making it work for myself. Thank you, though. – Amber May 23 '18 at 17:36

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.