SPSS Statistics

 View Only
  • 1.  PivotTable.DataCellArray() very slow

    Posted Sat December 12, 2020 04:28 PM
    Hi,

    Given the code snippet below it takes 3 minutes to get the requested DataCells object when applied to a PivotTable consisting of 1500 rows.
    When applied to a much smaller PivotTable the result is immediate.

    The calling syntax includes the line:
    set TABLERENDER = FULL.  

    I'm using SPSS 25.0.0.2 and Python 2.7.18

    Help in getting output faster would be greatly appreciated.

    Thanks
    Kees Smit
    ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    def getTable (outputDoc, tableNr):
    # If tableNr == 3 then the third PivotTable in outputDoc will be returned
    objItems = outputDoc.GetOutputItems()
    maxNumber = objItems.Size()
    numberFound = 0
    for outputItem in range (maxNumber):
    item = objItems.GetItemAt(outputItem)
    if item.GetType()== SpssClient.OutputItemType.PIVOT:
    numberFound +=1
    if numberFound == tableNr:
    break
    item = objItems.GetItemAt(outputItem)
    objPivotTable = item.GetSpecificType()
    return objPivotTable

    myPivot = getTable (outputDoc,tableNr)
    #This try: except clause does not help
    try:
    if myPivot.IsLegacyTableCompatible():
    myPivot.SetLegacyTableCompatible(False)
    except:
    pass

    dataCells = myPivot.DataCellArray()



    ------------------------------
    Kees Smit
    ------------------------------

    #SPSSStatistics


  • 2.  RE: PivotTable.DataCellArray() very slow

    IBM Champion
    Posted Sat December 12, 2020 04:51 PM
    Does your Viewer window have a huge number of tables in it?

    But don't , don't, don't use TABLERENDER FULL.  Let it do FAST, which is - well - fast

    --





  • 3.  RE: PivotTable.DataCellArray() very slow

    Posted Sun December 13, 2020 06:35 AM
    .. as was your answer. Thanks Jon.

    I changed the TABLERENDER  setting and got an instant respons. I did have to change some coding though as FAST produces other RowLabelArrays than FULL and I needed these RowLabelArrays. But all's well. Thanks again.

    Kees

    ------------------------------
    Kees Smit
    ------------------------------