SpssClient does not access all cells in a table body

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

SpssClient does not access all cells in a table body

la volta statistics

Hi all

I have a problem getting all the cells from a table body changed in text size and text form.

When I run the following syntax and Python code, the category 'Treatment' is not changed in size nor text form.

Surprisingly, the procedure works, when I use the Pivoting Trays to interchange rows and columns before I run the Python code.

 

Is this a bug? And is there e work around?  I am using SPSS 18.02.

 

Thanks for any help

Christian

 

 

data list list

 /Medi(F8.0) Sex(F8.1) Age(F8.2) .

begin data

1 1 44.25

2 1 52.92

1 1 37.21

1 1 60.87

2 1 58.69

2 2 43.17

1 2 44.93

1 1 34.19

1 2 39.96

2 1 63.04

End Data.

 

Var Label Medi 'Treatment'.

Val Label Medi 1 'Verum'

               2 'Palcebo'.

 

Var Label Sex "Gender".

Val Label Sex 1 "male"

              2 "female".

 

Compute Pat = 1.

Var Label Pat "Total".

VaL Label Pat 1 " ".

 

CTABLES

 /FORMAT EMPTY = " "

 /VLABELS VARIABLES=Medi sex Age DISPLAY=DEFAULT

 /TABLE Pat [c] [Count " " F8.0]                          +

        sex [C] [COUNT "N" F8.0, COLPCT.COUNT "%" PCT8.1] 

    BY Medi [c]

 /Titles TITLE = "My Table 2"

 /SLABELS POSITION=ROW

 /CATEGORIES VARIABLES = Medi ORDER=A KEY=VALUE EMPTY=INCLUDE TOTAL=YES POSITION=AFTER

 /CATEGORIES VARIABLES=sex ORDER=A KEY=VALUE EMPTY=INCLUDE.

 

BEGIN PROGRAM.

import SpssClient

SpssClient.StartClient()

OutputDoc = SpssClient.GetDesignatedOutputDoc()

OutputItems = OutputDoc.GetOutputItems()

 

for index in range(OutputItems.Size()):

      OutputItem = OutputItems.GetItemAt(index)

      if OutputItem.GetType() == SpssClient.OutputItemType.PIVOT:

            if OutputItem.GetSpecificType().GetTitleText().lower()  == "My Table 2".lower() :

                  PivotTable = OutputItem.GetSpecificType()

                  PivotTable.SelectTableBody()

                  PivotTable.SetUpdateScreen(False)

 

                  PivotTable.SetTextFont("Arial")

                  PivotTable.SetTextSize(16)

                 

                  PivotTable.SetUpdateScreen(True)

 

           

SpssClient.StopClient()

END PROGRAM.

 

 

**********************************
la volta statistics

Christian Schmidhauser, Dr.phil.II
Weinbergstrasse 108
CH-8006 Zürich
Tel: +41 (043) 233 98 01
Fax: +41 (043) 233 98 02
email:
[hidden email] 
Web: www.lavolta.ch

 

Reply | Threaded
Open this post in threaded view
|

Re: SpssClient does not access all cells in a table body

John F Hall
It always works if you copy the table to Word and change the fonts etc. in that.  Why make things complicated?
 
I presume you meant 'Pacebo'.
----- Original Message -----
Sent: Monday, April 26, 2010 5:23 PM
Subject: SpssClient does not access all cells in a table body

Hi all

I have a problem getting all the cells from a table body changed in text size and text form.

When I run the following syntax and Python code, the category 'Treatment' is not changed in size nor text form.

Surprisingly, the procedure works, when I use the Pivoting Trays to interchange rows and columns before I run the Python code.

 

Is this a bug? And is there e work around?  I am using SPSS 18.02.

 

Thanks for any help

Christian

 

 

data list list

 /Medi(F8.0) Sex(F8.1) Age(F8.2) .

begin data

1 1 44.25

2 1 52.92

1 1 37.21

1 1 60.87

2 1 58.69

2 2 43.17

1 2 44.93

1 1 34.19

1 2 39.96

2 1 63.04

End Data.

 

Var Label Medi 'Treatment'.

Val Label Medi 1 'Verum'

               2 'Palcebo'.

 

Var Label Sex "Gender".

Val Label Sex 1 "male"

              2 "female".

 

Compute Pat = 1.

Var Label Pat "Total".

VaL Label Pat 1 " ".

 

CTABLES

 /FORMAT EMPTY = " "

 /VLABELS VARIABLES=Medi sex Age DISPLAY=DEFAULT

 /TABLE Pat [c] [Count " " F8.0]                          +

        sex [C] [COUNT "N" F8.0, COLPCT.COUNT "%" PCT8.1] 

    BY Medi [c]

 /Titles TITLE = "My Table 2"

 /SLABELS POSITION=ROW

 /CATEGORIES VARIABLES = Medi ORDER=A KEY=VALUE EMPTY=INCLUDE TOTAL=YES POSITION=AFTER

 /CATEGORIES VARIABLES=sex ORDER=A KEY=VALUE EMPTY=INCLUDE.

 

BEGIN PROGRAM.

import SpssClient

SpssClient.StartClient()

OutputDoc = SpssClient.GetDesignatedOutputDoc()

OutputItems = OutputDoc.GetOutputItems()

 

for index in range(OutputItems.Size()):

      OutputItem = OutputItems.GetItemAt(index)

      if OutputItem.GetType() == SpssClient.OutputItemType.PIVOT:

            if OutputItem.GetSpecificType().GetTitleText().lower()  == "My Table 2".lower() :

                  PivotTable = OutputItem.GetSpecificType()

                  PivotTable.SelectTableBody()

                  PivotTable.SetUpdateScreen(False)

 

                  PivotTable.SetTextFont("Arial")

                  PivotTable.SetTextSize(16)

                 

                  PivotTable.SetUpdateScreen(True)

 

           

SpssClient.StopClient()

END PROGRAM.

 

 

**********************************
la volta statistics

Christian Schmidhauser, Dr.phil.II
Weinbergstrasse 108
CH-8006 Zürich
Tel: +41 (043) 233 98 01
Fax: +41 (043) 233 98 02
email:
[hidden email] 
Web: www.lavolta.ch

 

Reply | Threaded
Open this post in threaded view
|

Re: SpssClient does not access all cells in a table body

Jon K Peck
In reply to this post by la volta statistics

That top grouping layer doesn't seem to respond to the formatting apis, but for what you are doing, I would just create a tablelook with the styling you want and apply that.  It is more efficient anyway.

HTH,
Jon Peck
SPSS, an IBM Company
[hidden email]
312-651-3435



From: la volta statistics <[hidden email]>
To: [hidden email]
Date: 04/26/2010 09:16 AM
Subject: [SPSSX-L] SpssClient does not access all cells in a table body
Sent by: "SPSSX(r) Discussion" <[hidden email]>





Hi all
I have a problem getting all the cells from a table body changed in text size and text form.
When I run the following syntax and Python code, the category 'Treatment' is not changed in size nor text form.
Surprisingly, the procedure works, when I use the Pivoting Trays to interchange rows and columns before I run the Python code.
 
Is this a bug? And is there e work around?  I am using SPSS 18.02.
 
Thanks for any help
Christian
 
 
data list list
 /Medi(F8.0) Sex(F8.1) Age(F8.2) .
begin data
1 1 44.25
2 1 52.92
1 1 37.21
1 1 60.87
2 1 58.69
2 2 43.17
1 2 44.93
1 1 34.19
1 2 39.96
2 1 63.04
End Data.
 
Var Label Medi 'Treatment'.
Val Label Medi 1 'Verum'
               2 'Palcebo'.
 
Var Label Sex "Gender".
Val Label Sex 1 "male"
              2 "female".
 
Compute Pat = 1.
Var Label Pat "Total".
VaL Label Pat 1 " ".
 
CTABLES
 /FORMAT EMPTY = " "
 /VLABELS VARIABLES=Medi sex Age DISPLAY=DEFAULT
 /TABLE Pat [c] [Count " " F8.0]                          +
        sex [C] [COUNT "N" F8.0, COLPCT.COUNT "%" PCT8.1] 
    BY Medi [c]
 /Titles TITLE = "My Table 2"
 /SLABELS POSITION=ROW
 /CATEGORIES VARIABLES = Medi ORDER=A KEY=VALUE EMPTY=INCLUDE TOTAL=YES POSITION=AFTER
 /CATEGORIES VARIABLES=sex ORDER=A KEY=VALUE EMPTY=INCLUDE.
 
BEGIN PROGRAM.
import SpssClient
SpssClient.StartClient()
OutputDoc = SpssClient.GetDesignatedOutputDoc()
OutputItems = OutputDoc.GetOutputItems()
 
for index in range(OutputItems.Size()):
      OutputItem = OutputItems.GetItemAt(index)
      if OutputItem.GetType() == SpssClient.OutputItemType.PIVOT:
            if OutputItem.GetSpecificType().GetTitleText().lower()  == "My Table 2".lower() :
                  PivotTable = OutputItem.GetSpecificType()
                  PivotTable.SelectTableBody()
                  PivotTable.SetUpdateScreen(False)
 
                  PivotTable.SetTextFont("Arial")
                  PivotTable.SetTextSize(16)
                 
                  PivotTable.SetUpdateScreen(True)
 
           
SpssClient.StopClient()
END PROGRAM.
 
 
**********************************
la volta statistics

Christian Schmidhauser, Dr.phil.II
Weinbergstrasse 108
CH-8006 Zürich
Tel: +41 (043) 233 98 01
Fax: +41 (043) 233 98 02
email:
mailto:schmidhauser@...
Web:
www.lavolta.ch
 

Reply | Threaded
Open this post in threaded view
|

AW: [SPSSX-L] SpssClient does not access all cells in a table body

la volta statistics

Thanks Jon fort the answer.

So it is a bug. I actually noticed, that when I use for example SetTextSize(16) with the python script and open the table in the viewer subsequently, the formatting toolbar does not show the correct size nor font after the python script has changed them (except the grouping layer).

 

The reason why I don’t want to use tablelook for this purpose is, that I need a script, with which I can dynamically for each table many aspects of the table not only text size and font. The script is not finished yet.

Shall I report this bug to SPSS?

Christian

 

 

**********************************
la volta statistics

Christian Schmidhauser, Dr.phil.II
Wein
bergstrasse 108
CH-8006 Zürich
Tel: +41 (043) 233 98 01
Fax: +41 (043) 233 98 02
email:
[hidden email] 
Web: www.lavolta.ch


Von: Jon K Peck [mailto:[hidden email]]
Gesendet: Montag, 26. April 2010 20:55
An: la volta statistics
Cc: [hidden email]
Betreff: Re: [SPSSX-L] SpssClient does not access all cells in a table body

 


That top grouping layer doesn't seem to respond to the formatting apis, but for what you are doing, I would just create a tablelook with the styling you want and apply that.  It is more efficient anyway.

HTH,
Jon Peck
SPSS, an IBM Company
[hidden email]
312-651-3435


From:

la volta statistics <[hidden email]>

To:

[hidden email]

Date:

04/26/2010 09:16 AM

Subject:

[SPSSX-L] SpssClient does not access all cells in a table body

Sent by:

"SPSSX(r) Discussion" <[hidden email]>

 





Hi all
I have a problem getting all the cells from a table body changed in text size and text form.
When I run the following syntax and Python code, the category 'Treatment' is not changed in size nor text form.
Surprisingly, the procedure works, when I use the Pivoting Trays to interchange rows and columns before I run the Python code.
 
Is this a bug? And is there e work around?  I am using SPSS 18.02.
 
Thanks for any help
Christian
 
 
data list list
 /Medi(F8.0) Sex(F8.1) Age(F8.2) .
begin data
1 1 44.25
2 1 52.92
1 1 37.21
1 1 60.87
2 1 58.69
2 2 43.17
1 2 44.93
1 1 34.19
1 2 39.96
2 1 63.04
End Data.
 
Var Label Medi 'Treatment'.
Val Label Medi 1 'Verum'
               2 'Palcebo'.
 
Var Label Sex "Gender".
Val Label Sex 1 "male"
              2 "female".
 
Compute Pat = 1.
Var Label Pat "Total".
VaL Label Pat 1 " ".
 
CTABLES
 /FORMAT EMPTY = " "
 /VLABELS VARIABLES=Medi sex Age DISPLAY=DEFAULT
 /TABLE Pat [c] [Count " " F8.0]                          +
        sex [C] [COUNT "N" F8.0, COLPCT.COUNT "%" PCT8.1] 
    BY Medi [c]
 /Titles TITLE = "My Table 2"
 /SLABELS POSITION=ROW
 /CATEGORIES VARIABLES = Medi ORDER=A KEY=VALUE EMPTY=INCLUDE TOTAL=YES POSITION=AFTER
 /CATEGORIES VARIABLES=sex ORDER=A KEY=VALUE EMPTY=INCLUDE.
 
BEGIN PROGRAM.
import SpssClient
SpssClient.StartClient()
OutputDoc = SpssClient.GetDesignatedOutputDoc()
OutputItems = OutputDoc.GetOutputItems()
 
for index in range(OutputItems.Size()):
      OutputItem = OutputItems.GetItemAt(index)
      if OutputItem.GetType() == SpssClient.OutputItemType.PIVOT:
            if OutputItem.GetSpecificType().GetTitleText().lower()  == "My Table 2".lower() :
                  PivotTable = OutputItem.GetSpecificType()
                  PivotTable.SelectTableBody()
                  PivotTable.SetUpdateScreen(False)
 
                  PivotTable.SetTextFont("Arial")
                  PivotTable.SetTextSize(16)
                 
                  PivotTable.SetUpdateScreen(True)
 
           
SpssClient.StopClient()
END PROGRAM.
 
 
**********************************
la volta statistics

Christian Schmidhauser, Dr.phil.II
Weinbergstrasse 108
CH-8006 Zürich
Tel: +41 (043) 233 98 01
Fax: +41 (043) 233 98 02
email:
[hidden email]
Web:
www.lavolta.ch
 

Reply | Threaded
Open this post in threaded view
|

Re: SpssClient does not access all cells in a table body

SPSS Support-2
In reply to this post by la volta statistics

Hi Christian,

Jon's filed a bug report on this and I've opened a support case for the issue. A developer filed a related bug, noting that the problem affects pivot table editor manual selection of all of the contents of a table's body when done manually via the menus, as well as when done via scripting. You can manually select just that one dimension manually and apply changes to it.

David Nichols
SPSS, an IBM Company

From: la volta statistics <[hidden email]>
To: [hidden email]
Date: 04/27/2010 02:21 AM
Subject: AW: [SPSSX-L] SpssClient does not access all cells in a table body
Sent by: "SPSSX(r) Discussion" <[hidden email]>





Thanks Jon fort the answer.
So it is a bug. I actually noticed, that when I use for example SetTextSize(16) with the python script and open the table in the viewer subsequently, the formatting toolbar does not show the correct size nor font after the python script has changed them (except the grouping layer).
 
The reason why I don’t want to use tablelook for this purpose is, that I need a script, with which I can dynamically for each table many aspects of the table not only text size and font. The script is not finished yet.
Shall I report this bug to SPSS?
Christian
 
 
**********************************
la volta statistics

Christian Schmidhauser, Dr.phil.II
Weinbergstrasse 108
CH-8006 Zürich
Tel: +41 (043) 233 98 01
Fax: +41 (043) 233 98 02
email:
mailto:schmidhauser@...
Web:
www.lavolta.ch



Von: Jon K Peck [mailto:peck@...]
Gesendet:
Montag, 26. April 2010 20:55
An:
la volta statistics
Cc:
[hidden email]
Betreff:
Re: [SPSSX-L] SpssClient does not access all cells in a table body

 

That top grouping layer doesn't seem to respond to the formatting apis, but for what you are doing, I would just create a tablelook with the styling you want and apply that.  It is more efficient anyway.


HTH,

Jon Peck
SPSS, an IBM Company
[hidden email]
312-651-3435

From: la volta statistics <[hidden email]>
To: [hidden email]
Date: 04/26/2010 09:16 AM
Subject: [SPSSX-L] SpssClient does not access all cells in a table body
Sent by: "SPSSX(r) Discussion" <[hidden email]>

 






Hi all

I have a problem getting all the cells from a table body changed in text size and text form.

When I run the following syntax and Python code, the category 'Treatment' is not changed in size nor text form.

Surprisingly, the procedure works, when I use the Pivoting Trays to interchange rows and columns before I run the Python code.

 
Is this a bug? And is there e work around?  I am using SPSS 18.02.
 
Thanks for any help

Christian

 
 
data list list

/Medi(F8.0) Sex(F8.1) Age(F8.2) .

begin data

1 1 44.25
2 1 52.92

1 1 37.21

1 1 60.87

2 1 58.69

2 2 43.17

1 2 44.93

1 1 34.19

1 2 39.96

2 1 63.04

End Data.
 
Var Label Medi 'Treatment'.

Val Label Medi 1 'Verum'

              2 'Palcebo'.

 
Var Label Sex "Gender".

Val Label Sex 1 "male"

             2 "female".

 
Compute Pat = 1.

Var Label Pat "Total".

VaL Label Pat 1 " ".

 
CTABLES

/FORMAT EMPTY = " "

/VLABELS VARIABLES=Medi sex Age DISPLAY=DEFAULT

/TABLE Pat [c] [Count " " F8.0]                          +

       sex [C] [COUNT "N" F8.0, COLPCT.COUNT "%" PCT8.1]  
   BY Medi [c]

/Titles TITLE = "My Table 2"

/SLABELS POSITION=ROW

/CATEGORIES VARIABLES = Medi ORDER=A KEY=VALUE EMPTY=INCLUDE TOTAL=YES POSITION=AFTER

/CATEGORIES VARIABLES=sex ORDER=A KEY=VALUE EMPTY=INCLUDE.

 
BEGIN PROGRAM.

import SpssClient

SpssClient.StartClient()

OutputDoc = SpssClient.GetDesignatedOutputDoc()

OutputItems = OutputDoc.GetOutputItems()

 
for index in range(OutputItems.Size()):

     OutputItem = OutputItems.GetItemAt(index)

     if OutputItem.GetType() == SpssClient.OutputItemType.PIVOT:

           if OutputItem.GetSpecificType().GetTitleText().lower()  == "My Table 2".lower() :

                 PivotTable = OutputItem.GetSpecificType()

                 PivotTable.SelectTableBody()

                 PivotTable.SetUpdateScreen(False)

 
                 PivotTable.SetTextFont("Arial")

                 PivotTable.SetTextSize(16)

                 
                 PivotTable.SetUpdateScreen(True)

 
           
SpssClient.StopClient()

END PROGRAM.

 
 
**********************************
la volta statistics

Christian Schmidhauser, Dr.phil.II
Weinbergstrasse 108
CH-8006 Zürich
Tel: +41 (043) 233 98 01
Fax: +41 (043) 233 98 02
email:
mailto:schmidhauser@...
Web:
www.lavolta.ch