Looking for a hand with a script

Discussion created by cbates0372 on Apr 21, 2011
Latest reply on May 3, 2011 by lpugh01
Hi Everyone,

I will try my best to explain the problem that I am having in a clear and concise manner.

I have a feature class with a ton of attribute data in a Local File Geodatabase. I need to move the feature class to an enterprise SDE Geodatabase, so that I can play with it in an Oracle 11g Database. I have done this countless times by simply importing the feature class into sde, connecting to the sde database via a virtual command line, and using SQLPLUS commands to query the data I need and create pivot tables etc. The feature class that I am currently working with has several field names which have been (for whatever reason) named insanely long. The import to geodatabase tool will only work when these file names are shortened to less than 31 character. I am trying to write a script that will do this by removing the "_" characters in the names.
What I have so far is:

# ---------------------------------------------------------------------------
# Created: April 2011
# Created By: Chris Bates
# Description: The idea of this script is to read the fields of a feature class
#              into a list, single out those field names that are over 31
#              characters long, and rename them based by removing the "_"
#              characters in the name. A new field will be added with the new
#              names and values from the old field.
# Inputs: Feature Class
# Outputs: Feature Class
# ---------------------------------------------------------------------------

# Import arcpy module
import arcpy,sys,os,string
from arcpy import env

# Set Overwrite On
arcpy.env.overwriteOutput = True

    inputFC = sys.argv[1]
    fieldList = arcpy.ListFields(inputFC)
    for field in fieldList:
        fieldname =
        fieldlength = len(fieldname)

        if fieldlength > 31:
            newname = fieldname.replace('_','')
            name = str(newname)
            arcpy.AddMessage("Shortening: "+fieldname+" to the more appropriate: "+name)

            # Process: Add Field
            arcpy.AddField_management(inputFC, name, "LONG", "", "", "", "", "NULLABLE", "NON_REQUIRED", "")
            # Process: Calculate Field
            ##arcpy.CalculateField_management(inputFC, name, <??????>, "PYTHON", "")
    print arcpy.GetMessages(2)

The problem I am having is right above, I can add the fields with the names I need beautifully, but I have no idea how to grab the original data values and put it in these fields. Once I do this I will then Delete the old fields.

Any thoughts would be awesome,