Hi All,
I am producing some output that have table titles Q 1 blah Q 5 blah Q 7 blah Q 2 blah Q 6 blah (The numbers can change for different projects) I want to use python to re-order the tables into Ascending order, I'm guessing I need the Viewer module and potentially the spssaux module? Does anyone no how I can achieve this? My guess is that I have to create an array with all table titles using regular expression and then order this array and sort the output view by this, but I'm not sure of how to do this? Again here is my 'guess' code of how to do some of it, if it's helpful to anyone else? begin program. import spss,spssaux, viewer, re, string spssappObj = viewer.spssapp() outputdoc = spssappObj.GetDesignatedOutput() objItems = outputdoc.Items outputdoc.ClearSelection() for I in range(objItems.Count): objItem = objItems.GetItem(i) intSPSSType = objItem.SPSSType if (intSPSSType == 5 and objItem.Label == "^Q "): objItem.Selected = True This should access the output view and select all tables with a 'Q ', but I'm not sure of where to go after this? Cheers Mike ______________________________________________________________________ This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email ______________________________________________________________________ |
You could do this (from either Python or SaxBasic), I think, using the Cut and Paste OLE methods available for items in the Viewer document and using, for Python, the viewer module to access it, but I would suggest instead that you generate the syntax from Python code in an order that will create the tables initially already sorted.
-Jon Peck -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Michael Pearmain Sent: Tuesday, December 12, 2006 5:06 AM To: [hidden email] Subject: [SPSSX-L] Viewer Module and Python Hi All, I am producing some output that have table titles Q 1 blah Q 5 blah Q 7 blah Q 2 blah Q 6 blah (The numbers can change for different projects) I want to use python to re-order the tables into Ascending order, I'm guessing I need the Viewer module and potentially the spssaux module? Does anyone no how I can achieve this? My guess is that I have to create an array with all table titles using regular expression and then order this array and sort the output view by this, but I'm not sure of how to do this? Again here is my 'guess' code of how to do some of it, if it's helpful to anyone else? begin program. import spss,spssaux, viewer, re, string spssappObj = viewer.spssapp() outputdoc = spssappObj.GetDesignatedOutput() objItems = outputdoc.Items outputdoc.ClearSelection() for I in range(objItems.Count): objItem = objItems.GetItem(i) intSPSSType = objItem.SPSSType if (intSPSSType == 5 and objItem.Label == "^Q "): objItem.Selected = True This should access the output view and select all tables with a 'Q ', but I'm not sure of where to go after this? Cheers Mike ______________________________________________________________________ This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email ______________________________________________________________________ |
In reply to this post by Mike P-5
Thanks once again Jon,
I'll have to look into " using the Cut and Paste OLE methods available for items in the Viewer document and using, for Python, the viewer module to access it" As the tables are produced from two or more insert files Mike -----Original Message----- From: Peck, Jon [mailto:[hidden email]] Sent: 12 December 2006 16:53 To: Michael Pearmain; [hidden email] Subject: RE: [SPSSX-L] Viewer Module and Python You could do this (from either Python or SaxBasic), I think, using the Cut and Paste OLE methods available for items in the Viewer document and using, for Python, the viewer module to access it, but I would suggest instead that you generate the syntax from Python code in an order that will create the tables initially already sorted. -Jon Peck -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Michael Pearmain Sent: Tuesday, December 12, 2006 5:06 AM To: [hidden email] Subject: [SPSSX-L] Viewer Module and Python Hi All, I am producing some output that have table titles Q 1 blah Q 5 blah Q 7 blah Q 2 blah Q 6 blah (The numbers can change for different projects) I want to use python to re-order the tables into Ascending order, I'm guessing I need the Viewer module and potentially the spssaux module? Does anyone no how I can achieve this? My guess is that I have to create an array with all table titles using regular expression and then order this array and sort the output view by this, but I'm not sure of how to do this? Again here is my 'guess' code of how to do some of it, if it's helpful to anyone else? begin program. import spss,spssaux, viewer, re, string spssappObj = viewer.spssapp() outputdoc = spssappObj.GetDesignatedOutput() objItems = outputdoc.Items outputdoc.ClearSelection() for I in range(objItems.Count): objItem = objItems.GetItem(i) intSPSSType = objItem.SPSSType if (intSPSSType == 5 and objItem.Label == "^Q "): objItem.Selected = True This should access the output view and select all tables with a 'Q ', but I'm not sure of where to go after this? Cheers Mike ______________________________________________________________________ This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email ______________________________________________________________________ ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ ______________________________________________________________________ This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email ______________________________________________________________________ |
Free forum by Nabble | Edit this page |