LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (March 2007)Back to main SPSSX-L pageJoin or leave SPSSX-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 19 Mar 2007 18:09:55 +0100
Reply-To:     la volta statistics <schmidhauser@lavolta.ch>
Sender:       "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From:         la volta statistics <schmidhauser@lavolta.ch>
Subject:      finding line break using Python
Content-Type: text/plain; charset="iso-8859-1"

Dear all

I would like to find the position of line breaks in the title of a table using Python. It seems that the normal '\n' as a search criteria does not work (see example below). A second problem I have, is that I get an UnicodeEncodeError, when I use a character such as '®' in the title (for generating this error, activate the print strOldTitle line). Can somebody help me? Thank in advance, Christian

DATA LIST FREE /var1 var2 . BEGIN DATA 1 2 END DATA. * Custom Tables. CTABLES /VLABELS VARIABLES=var1 var2 DISPLAY=DEFAULT /TABLE var2 BY var1 [COUNT F40.0] /CATEGORIES VARIABLES=var1 var2 ORDER=A KEY=VALUE EMPTY=EXCLUDE /TITLES TITLE= 'First line®' 'second line®' 'third line®'.

BEGIN PROGRAM. import spss,viewer spssappObj = viewer.spssapp() outputdoc = spssappObj.GetDesignatedOutput() objItems = outputdoc.Items outputdoc.ClearSelection()

for i in range(objItems.Count): objItem = objItems.GetItem(i) if objItem.SPSSType == 5 : objItem.Selected = True objPivotTable = objItem.ActivateTable() strOldTitle = objPivotTable.TitleText # print strOldTitle print strOldTitle.find("\n") 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@lavolta.ch internet: http://www.lavolta.ch/


Back to: Top of message | Previous page | Main SPSSX-L page