Topic
  • 2 replies
  • Latest Post - ‏2012-12-14T23:25:28Z by SystemAdmin
spssdeveloper
spssdeveloper
16 Posts

Pinned topic python script

‏2012-12-14T23:13:32Z |
Hi
I am trying to call the following script from external python command prompt. It gives error after the first for loop is done. I am new to python and I am not sure if it has something to do with indent. Could you please help?
import SpssClient
SpssClient.StartClient()
OutputDoc=SpssClient.OpenOutputDoc('c:/temp/test.spv')
OutputUI = OutputDoc.GetOutputUI()
OutputUI.SetVisible(True)
OutputDoc.ClearSelection()
OutputDoc.SelectAllLogs()
OutputDoc.Delete()
OutputDoc.SelectAllNotes()
OutputDoc.Delete()
OutputDoc.SelectAllText()
OutputDoc.Delete()
OutputDoc.SelectAllTitles()
OutputDoc.Delete()
OutputDoc.SelectAllWarnings()
OutputDoc.Delete()
OutputDoc.ClearSelection()
OutputItems = OutputDoc.GetOutputItems()
i = OutputItems.Size()
for index in range(0,i):
OutputItem = OutputItems.GetItemAt(index)
if OutputItem.GetType() == SpssClient.OutputItemType.PIVOT:
PivotTable = OutputItem.GetSpecificType()
if PivotTable.GetTitleText() == "Case Processing Summary":
OutputItem.SetSelected(True)
OutputDoc.Delete()
OutputDoc.ClearSelection()
OutputDoc.ClearSelection()
k = OutputItems.Size()
for index1 in range(0,k):
OutputItem = OutputItems.GetItemAt(index1)
if OutputItem.GetType() == SpssClient.OutputItemType.PIVOT:
PivotTable = OutputItem.GetSpecificType()
OutputItem.SetSelected(True)
RowLabels = PivotTable.RowLabelArray()
ColLabels = PivotTable.ColumnLabelArray()
dataCells = PivotTable.DataCellArray()
layerlabels = PivotTable.LayerLabelArray()
if RowLabels.GetNumRows() <= 4:
OutputDoc.Delete()
OutputDoc.ClearSelection()
else:
for j in range(RowLabels.GetNumRows()):
if(RowLabels.GetValueAt(j,1).isdigit()):
RowLabels.SetValueAt(j,1,str(int(RowLabels.GetValueAt(j,1))-1))
OutputDoc.ClearSelection()
RowLabels.HideLabelsWithDataAt(0,1)
OutputDoc.SaveAs('c:/temp/test.spv')
OutputDoc.CloseDocument()
SpssClient.Exit()
SpssClient.StopClient()
Thanks
Updated on 2012-12-14T23:25:28Z at 2012-12-14T23:25:28Z by SystemAdmin
  • spssdeveloper
    spssdeveloper
    16 Posts

    Re: python script

    ‏2012-12-14T23:15:33Z  
    Sorry since I pasted the syntax the indent were gone. I ahve atatched the python script.

    Attachments

  • SystemAdmin
    SystemAdmin
    2077 Posts

    Re: python script

    ‏2012-12-14T23:25:28Z  
    Sorry since I pasted the syntax the indent were gone. I ahve atatched the python script.
    If you want to paste program code intact into a message, precede it with
    LSBcodeRSB
    and end it the same way. LSB is the left curly bracket, and RSB is the right bracket.

    It isn't sufficient to just say you got an error message. You need to post what the message actually said.