Adding Tablelooks to table with Python

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

Adding Tablelooks to table with Python

la volta statistics

Hi all

 

with Sax Basic it is/was possible to add a specific Tablelooks to a table in the viewer (e.g. objPivotTable.TableLook = <Sting path and filename> ).

 

Is there a possibility to do something similar with Python? I am using SPSS 18.

 

TIA.

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:
[hidden email] 
Web:
www.lavolta.ch

 

Reply | Threaded
Open this post in threaded view
|

Re: Adding Tablelooks to table with Python

J. R. Carroll
Hi Christian (Dr. Schmidhauser),

To answer your question about Python:

If you check the scripting PDF that comes with SPSS (Im using v17 and it came with) called "SPSS Statistics Scripting Guide" it gives some insight on how this can be done (appears to be relatively simple).  You can find this guide by opening up SPSS and selecting it under "help>programmability>scripting" it should open the pdf guide for you.  On page 92 there is a reference for "SetTableLook Method".  Once you locate on your PC where the .stt file is (the file containing the table-look parameters) you should just be able to reference and it effectively change the table to whatever you want. 

SetTableLook Method
Applies a predefined table look.

Syntax
objSpssPivotTable.SetTableLook(filename)

Parameters
"filename" Path to the TableLook (.stt) file

You will need to "import SpssClient" for this to work.

If you need a more specific example or additional help on this let me know.

HTH

J. R. Carroll
Grad. Student in Pre-Doc Psychology at CSUS
Research Assistant for Just About Everyone.
Email:  [hidden email]   -or-   [hidden email]
Phone:  (916) 628-4204


On Mon, Aug 23, 2010 at 3:26 AM, la volta statistics <[hidden email]> wrote:

Hi all

 

with Sax Basic it is/was possible to add a specific Tablelooks to a table in the viewer (e.g. objPivotTable.TableLook = <Sting path and filename> ).

 

Is there a possibility to do something similar with Python? I am using SPSS 18.

 

TIA.

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:
[hidden email] 
Web:
www.lavolta.ch

 


Reply | Threaded
Open this post in threaded view
|

AW: Adding Tablelooks to table with Python

la volta statistics

Hi Justin

 

Thanks that helped

 

HTH Christian

 

BEGIN PROGRAM.

import SpssClient

SpssClient.StartClient()

OutputDoc = SpssClient.GetDesignatedOutputDoc()

OutputItems = OutputDoc.GetOutputItems()

 

i = OutputItems.Size() #counts the items zero-based

 

for index in range(i-1,0,-1):

   OutputItem = OutputItems.GetItemAt(index)

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

      PivotTable = OutputItem.GetSpecificType()

      PivotTable.SetTableLook("C:\Programme\SPSSInc\PASWStatistics18\Looks\Academic.stt")

      break

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


Von: Justin Carroll [mailto:[hidden email]]
Gesendet: Montag, 23. August 2010 13:04
An: la volta statistics
Cc: [hidden email]
Betreff: Re: Adding Tablelooks to table with Python

 

Hi Christian (Dr. Schmidhauser),

To answer your question about Python:

If you check the scripting PDF that comes with SPSS (Im using v17 and it came with) called "SPSS Statistics Scripting Guide" it gives some insight on how this can be done (appears to be relatively simple).  You can find this guide by opening up SPSS and selecting it under "help>programmability>scripting" it should open the pdf guide for you.  On page 92 there is a reference for "SetTableLook Method".  Once you locate on your PC where the .stt file is (the file containing the table-look parameters) you should just be able to reference and it effectively change the table to whatever you want. 

SetTableLook Method
Applies a predefined table look.

Syntax
objSpssPivotTable.SetTableLook(filename)

Parameters
"filename" Path to the TableLook (.stt) file


You will need to "import SpssClient" for this to work.

If you need a more specific example or additional help on this let me know.

HTH


J. R. Carroll
Grad. Student in Pre-Doc Psychology at CSUS
Research Assistant for Just About Everyone.
Email:  [hidden email]   -or-   [hidden email]
Phone:  (916) 628-4204

On Mon, Aug 23, 2010 at 3:26 AM, la volta statistics <[hidden email]> wrote:

Hi all

 

with Sax Basic it is/was possible to add a specific Tablelooks to a table in the viewer (e.g. objPivotTable.TableLook = <Sting path and filename> ).

 

Is there a possibility to do something similar with Python? I am using SPSS 18.

 

TIA.

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:
[hidden email] 
Web:
www.lavolta.ch

 

 

Reply | Threaded
Open this post in threaded view
|

Re: Adding Tablelooks to table with Python

Jon K Peck
In reply to this post by J. R. Carroll

Note that if you don't want to write a script, you can apply a specific tableLook to a pivot table with the SPSSINC MODIFY TABLES extension command.  (Under the covers the command is using the same scripting api to do this.)

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



From: Justin Carroll <[hidden email]>
To: [hidden email]
Date: 08/23/2010 07:55 AM
Subject: Re: [SPSSX-L] Adding Tablelooks to table with Python
Sent by: "SPSSX(r) Discussion" <[hidden email]>





Hi Christian (Dr. Schmidhauser),

To answer your question about Python:

If you check the scripting PDF that comes with SPSS (Im using v17 and it came with) called "SPSS Statistics Scripting Guide" it gives some insight on how this can be done (appears to be relatively simple).  You can find this guide by opening up SPSS and selecting it under "help>programmability>scripting" it should open the pdf guide for you.  On page 92 there is a reference for "SetTableLook Method".  Once you locate on your PC where the .stt file is (the file containing the table-look parameters) you should just be able to reference and it effectively change the table to whatever you want. 

SetTableLook Method
Applies a predefined table look.

Syntax

objSpssPivotTable.SetTableLook(filename)

Parameters

"filename" Path to the TableLook (.stt) file


You will need to "import SpssClient" for this to work.

If you need a more specific example or additional help on this let me know.

HTH


J. R. Carroll
Grad. Student in Pre-Doc Psychology at CSUS
Research Assistant for Just About Everyone.
Email: 
jrc.csus@...   -or-   jrcarroll@...
Phone:  (916) 628-4204


On Mon, Aug 23, 2010 at 3:26 AM, la volta statistics <schmidhauser@...> wrote:
Hi all

 

with Sax Basic it is/was possible to add a specific Tablelooks to a table in the viewer (e.g. objPivotTable.TableLook = <Sting path and filename> ).

 

Is there a possibility to do something similar with Python? I am using SPSS 18.

 

TIA.

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