Merge Tables Produces Empty Output

562
1
03-23-2011 08:05 AM
LornaMurison
Occasional Contributor
Hello,
I'm trying to merge two tables together (have tried both .dbf and geodatabase) within a python script.  Everytime I do, I get an empty output.  The output table has all the fields that I require and the correct number of rows, except they are all populated with 0 or null.
I am doing this using field mapping with the code below:

# Convert the table views to geodatabase tables
gp.TableToGeodatabase_conversion (statTableV, workspace)
gp.TableToGeodatabase_conversion (pointValuesV, workspace)

# Prepare the field maps for the final table
#* Create the field mappings object\
fieldMappings = gp.createobject ("FieldMappings")
#* Create a UCID field map object and add the two UCID fields
fldmap_UCID = gp.CreateObject ("FieldMap")
fldmap_UCID.AddInputField(pointValuesV, "CATCH_02_3")
fldmap_UCID.AddInputField(statTableV, "UCID")
print "UCID input fields: " + str(fldmap_UCID.InputFieldCount)
#* Create a field map for temperature and add the two fields
fldmap_Temp = gp.createobject ("FieldMap")
fldmap_Temp.AddInputField(statTableV, "MEAN")
fldmap_Temp.AddInputField(pointValuesV, "RASTERVALU")
print "Temp input fields: " + str(fldmap_Temp.InputFieldCount)
#* Create both of the output fields and add them to the field mappings object
fld_UCID = fldmap_UCID.OutputField
fld_UCID.Name = "UCID"
fld_UCID.Type = "Text"
fld_UCID.Length = 9
fldmap_UCID.OutputField = fld_UCID
fieldMappings.AddFieldMap(fldmap_UCID)
fld_Temp = fldmap_Temp.OutputField
fld_Temp.Name = "Temp"
fld_Temp.Type = "Float"
fld_Temp.Precision = 5
fld_Temp.Scale = 1
fldmap_Temp.OutputField = fld_Temp
fieldMappings.AddFieldMap(fldmap_Temp)

# Merge the two tables
#gp.Merge_management (statTableV + ".dbf;" + pointValuesV + ".dbf", finalTable, fieldMappings)
gp.Merge_management (workspace + "/" + statTableV + ";" + workspace + "/" + pointValuesV, outWorkspace + "/" + finalTable, fieldMappings)
0 Kudos
1 Reply