Pivot Table (Data Management) (ArcInfo only) |
|
Release 9.2
Last modified November 29, 2010 |
![]() ![]() ![]() Print all topics in : "Tools" |
Sorts and summarizes the input table fields, based on the selected pivot field and value field, in the output table to reduce redundancy.
Illustration
Usage tips
Pivot Table is used to reduce redundant records and flatten one-to-many relationships.
If the pivot field is a numeric type, its value will be appended to its original field name in the output table.
Pivot Table can be used to normalize the one-to-many relationship between CAD objects and attribute tags created by Import From CAD in the Attrib table of the Staging Geodatabase.
The Input Field(s) parameter's Add Field button is used only in ModelBuilder. In ModelBuilder, where the preceding tool has not been run, or its derived data does not exist, the Input Field(s) parameter may not be populated with field names. The Add Field button allows you to add expected field(s) so you can complete the Pivot Table dialog and continue to build your model.
The following environments affect this tool: configKeyword, scratchWorkspace, and workspace.
Command line syntax
An overview of the Command Line window
PivotTable_management <in_table> <fields;fields...> <pivot_field> <value_field> <out_table>
Parameter | Explanation | Data Type |
<in_table> |
The table whose records will be pivoted. |
Table View |
<fields;fields...> |
The fields that define records to be included in the output table. The Add Field button, which is used only in ModelBuilder, allows you to add expected field(s) so you can complete the dialog and continue to build your model. |
Field |
<pivot_field> |
The field whose record values will be used to generate names of new fields in the output table. |
Field |
<value_field> |
The field containing values used to populate the new fields in the output table. |
Field |
<out_table> |
The table to be created. |
Table |
pivottable_management d:\workspace\attributes.dbf ENTID;LINKTYPE TABLEID LINKVALUE c:\workspace\attributes_pivot.dbf
Scripting syntax
About getting started with writing geoprocessing scripts
PivotTable_management (in_table, fields, pivot_field, value_field, out_table)
Parameter | Explanation | Data Type |
in_table (Required) |
The table whose records will be pivoted. |
Table View |
fields (Required) |
The fields that define records to be included in the output table. The Add Field button, which is used only in ModelBuilder, allows you to add expected field(s) so you can complete the dialog and continue to build your model. |
Field |
pivot_field (Required) |
The field whose record values will be used to generate names of new fields in the output table. |
Field |
value_field (Required) |
The field containing values used to populate the new fields in the output table. |
Field |
out_table (Required) |
The table to be created. |
Table |
# To create Points from the CAD block inserts pivoting on owner name. # Create the Geoprocessor object import arcgisscripting gp = arcgisscripting.create() # Script arguments... blocks = sys.argv[1] if blocks == '#': blocks = "C:/Test_data/CAD/MetroGAS/res00051_pc22j_ImportCAD1.mdb/blocks" # provide a default value if unspecified res00051_pc22j_dwg = sys.argv[2] if res00051_pc22j_dwg == '#': res00051_pc22j_dwg = "C:/Test_data/CAD/MetroGAS/res00051_pc22j.dwg" # provide a default value if unspecified Select_Set_Name = sys.argv[3] if Select_Set_Name == '#': Select_Set_Name = "[SetName] = 'COD_90_50M'" # provide a default value if unspecified # Local variables... Pivoted_AttrTags_by_OwnerID = "C:/Test_data/CAD/MetroGAS/res00051_pc22j_ImportCAD1.mdb/Attrib_PivotTable" Attrib_Table = "C:/Test_data/CAD/MetroGAS/res00051_pc22j_ImportCAD1.mdb/Attrib" Entities_Table = "C:/Test_data/CAD/MetroGAS/res00051_pc22j_ImportCAD1.mdb/Entity" joined = "joined" Output_Staging_Geodatabase = "C:/Test_data/CAD/MetroGAS/res00051_pc22j_ImportCAD1.mdb" points_new2 = "points_new" Point = "C:/Test_data/CAD/MetroGAS/res00051_pc22j_ImportCAD1.mdb/CADStaging/Point" points_new = "points_new" points_new3 = "points_new" try: # Process: Import from CAD...gp.ImportCAD_conversion("'C:/Test_data/CAD/MetroGAS/res00051_pc22j.dwg'", Output_Staging_Geodatabase, "", "Do_Not_Explode_Complex") # Process: Select Data... gp.SelectData_management(Output_Staging_Geodatabase, "CADStaging/Point", ) # Process: Make Layer... gp.MakeFeatureLayer_management(Point, points_new, "", "", "EntID EntID VISIBLE") # Process: Select Data (Entities Table)... gp.SelectData_management(Output_Staging_Geodatabase, "Entity", ) # Process: Add Join... gp.AddJoin_management(points_new, "EntID", Entities_Table, "EntID", "OUTER", ) # Process: Select Data (Attrib Table)... gp.SelectData_management(Output_Staging_Geodatabase, "Attrib", ) # Process: Make Table View... gp.MakeTableView_management(Attrib_Table, joined, Select_Set_Name, "", "EntID EntID VISIBLE;OwnerID OwnerID VISIBLE;AttrFlag AttrFlag VISIBLE;MSSet MSSet VISIBLE;AtrTag AtrTag VISIBLE;AtrHndl AtrHndl VISIBLE;AttrType AttrType VISIBLE;AttrStr AttrStr VISIBLE;AttrLong AttrLong VISIBLE;AttrDbl AttrDbl VISIBLE") # Process: Pivot Table... gp.PivotTable_management(joined, "'Attrib.OwnerID';'OwnerID'", "AttrTag", "AttrStr", Pivoted_AttrTags_by_OwnerID) # Process: Add Join2... gp.AddJoin_management(points_new2, "Point.EntID", Pivoted_AttrTags_by_OwnerID, "OwnerID", "INNER", ) # Process: Copy Features... gp.CopyFeatures_management(points_new3, blocks, "", "0", "0", "0") except: # If an error occurred while running a tool print the messages print gp.GetMessages()