0

In Arc 10.2 I have a script tool that uses arcpy.Append_management() to transfer .csv data into a freshly truncated feature class table. It works perfectly on all .csv tables except one in which it fails on just two particular columns. Instead of seeing data these columns are "Null" all the way down.

The names of these columns are "Type" and "Subtype", and both are "Text" fields.

"Type" should have values such as:

"Human-Land" and "Human-Marine"

"SubType" should have values like:

"Sub-Surface Flow" and "Water Course"

Rather than supply code (for now) I'm going to zero in on a peculiarity I found in the field mapping variable.

I acquired the field mapping by running "FeatureClasstoFeatureClass", and here is what it gave me for these two fields:

...;Type_ "Type_" true true false 255 Text 0 0 ,First,#,Temp_Layer,Type_,-1,-1;SubType_ "SubType_" true true false 255 Text 0 0 ,First,#,Temp_Layer,SubType_,-1,-1;...

Why did it add an underscore "_" to the end of the field name? None of the other field names have underscores added to them. I tried using the field mapping as Arc gave it to me, and I've also tried it with those underscores deleted. Both ways I still get those two fields filled in as "" all the way down.

Is this related to the problem? If so, why is this happening and what is the fix?

  • 3
    Type is illegal field name. – FelixIP Oct 4 '18 at 22:03
  • @FelixIP That certainly explains it. This ESRI page (pro.arcgis.com/en/pro-app/tool-reference/…) mentions some reserved words but "Type" isn't one of them, however I acknowledge the list is not exhaustive. Still, "SubType" isn't "Type". Are the letters "t-y-p-e" not allowed in sequence anywhere in a field name? – Waterman Oct 4 '18 at 22:17
  • 1
    Import your CSV into a more rigid format like personal geodatabase table before importing but as @FelixIP said Type is an illegal field name, have a look at a related answer gis.stackexchange.com/questions/123736/… regarding feature class names as SQL reserved words so change your csv header to csvType, csvSubtype to avoid using Type and SubType as your field names. – Michael Stimson Oct 4 '18 at 22:18
  • 1
    I hit the wall with Type name as well. It worked like a charm with shapefiles, until one day I decided to test script on features stored in fgdb. B-a-ad! – FelixIP Oct 4 '18 at 22:35
  • 1
    There is some inconsistency. Other notable examples include shapefiles with dashes (eg. Water-Line.shp) some tools will create them some will not, converting the dashes to underscores (eg. Water_Line.shp) others will return errors. – Michael Stimson Oct 4 '18 at 23:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.