Sign up ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am using Make Table View to copy data from one table to a table view object and in the process hide and/or rename some fields. When I output the data to a dbf it hides and/or renames the fields accordingly. When I output the data to a geodatabase, it hides the specified fields but does not rename the ones that should be renamed. Any ideas why this is happening?

EDIT: After some further testing, it looks like it is changing the field name, and not the field alias in the geodatabase. I tried changing to field.aliasName, but that did not work.

import arcpy
from arcpy import env

# Set the enviroment
env.workspace = '//GIS-SDE/ParcelData.mdb'
env.qualifiedFieldNames = False

# Get the fields from the G_AccountInfo table in ParcelData.mdb
fields = arcpy.ListFields("G_AccountInfo")

# Create a fieldinfo object
fieldinfo = arcpy.FieldInfo()

# Iterate through the fields and set them to fieldinfo
for field in fields:
    if == "ACCOUNT_NUM":
        fieldinfo.addField(, "ACCOUNT", "VISIBLE", "")
    elif == "OWNER_NAME1":
      fieldinfo.addField(, "OWNERNAME", "VISIBLE", "")
    elif == "OWNER_ADDRESS_LINE1":
      fieldinfo.addField(, "OWNERADDRESS1", "VISIBLE", "")
        fieldinfo.addField(,, "HIDDEN", "")

arcpy.MakeTableView_management ("G_AccountInfo", "AccountInfo", '//GIS-SDE/ParcelData.mdb', fieldinfo)

# Give the output table a unique name
output = '//GIS-SDE/ParcelData.mdb/cleaned_data'

# Add the table back to the gdb
arcpy.CopyRows_management("AccountInfo", output)
share|improve this question
When you make a copy of your table, do you want some fields to be removed/dropped, or just hidden? And others to be renamed, or just aliased? – PolyGeo Apr 26 '13 at 21:11
Yes. I would like some fields removed, and the other fields I need them to show a different column header name in the output table (renamed).. I believe that would be alias, correct? – user17596 Apr 28 '13 at 3:18

1 Answer 1

up vote 1 down vote accepted

Try the test code below which should create a test file geodatabase table called xxx, with three fields (FieldA, FieldB, FieldC) and inserts a single row. It then uses FieldInfo, MakeTableView and CopyRows to output a dBase, personal geodatabase and file geodatabase table with FieldA renamed to FieldD and Field B removed. I think this is what you are trying to do. If this works for you then comment out the code to create test data and replace my test tables, fields, etc with yours.

import arcpy

if arcpy.Exists("C:/temp/test.gdb"):
if arcpy.Exists("C:/temp/test.mdb"):
if arcpy.Exists("C:/temp/test.dbf"):

rows = arcpy.InsertCursor("C:/temp/test.gdb/xxx")
row = rows.newRow()
row.FieldA = "Test1"
row.FieldB = "Test2"
row.FieldC = "Test3"
del row,rows

intable = "C:/temp/test.gdb/xxx"
fields= arcpy.ListFields(intable)
fieldinfo = arcpy.FieldInfo()
for field in fields:
    if == "FieldA":
        fieldinfo.addField(, "FieldD", "VISIBLE", "")
    elif == "FieldB":
        fieldinfo.addField(,, "HIDDEN", "")
    elif == "FieldC":
        fieldinfo.addField(,, "VISIBLE", "")
arcpy.MakeTableView_management(intable, "xxx_view", "", "", fieldinfo)
arcpy.CopyRows_management("xxx_view", "C:/temp/test.dbf")
arcpy.CopyRows_management("xxx_view", "C:/temp/test.mdb/test")
arcpy.CopyRows_management("xxx_view", "C:/temp/test.gdb/test")
share|improve this answer
This works correctly. What is interesting is that the field name displays as FieldD (the correct changed name) in ArcCatalog and in the .mdb when viewed in Access, but it still shows as FieldA when viewed in ArcMap. A bug maybe? – user17596 Apr 29 '13 at 15:16

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.