Show Navigation | Hide Navigation
You are here:
Geoprocessing tool reference > Data Management toolbox > Table toolset > Tools

Pivot Table (Data Management) (ArcInfo only)

Release 9.2
Last modified November 29, 2010
E-mail This Topic Printable Version Give Us Feedback

Print all topics in : "Tools"


Related Topics

Sorts and summarizes the input table fields, based on the selected pivot field and value field, in the output table to reduce redundancy.


Illustration

Pivot Table illustration

Usage tips

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
Data types for geoprocessing tool parameters


Command line example

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

Data types for geoprocessing tool parameters


Script example

# 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()

Please visit the Feedback page to comment or give suggestions on ArcGIS Desktop Help.
Copyright © Environmental Systems Research Institute, Inc.