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 (July 2009)Back to main SPSSX-L pageJoin or leave SPSSX-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Tue, 21 Jul 2009 00:48:41 -0700
Reply-To:   Albert-Jan Roskam <fomcl@yahoo.com>
Sender:   "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From:   Albert-Jan Roskam <fomcl@yahoo.com>
Subject:   Re: spssaux.getShow("handles")
Comments:   To: JonPeck <peck@spss.com>
In-Reply-To:   <6CD9B6A6B6CCBA4FA497F07182F4EE830292ED7D@MIAEMAILEVS1.spss.com>
Content-Type:   text/plain; charset=iso-8859-1

Thank you very much! I tried it and it works perfectly! I just added a custom button to the spss menu bar. Even though cutting and pasting the file path is not a whole lot of work, this is still very handy because I do it all the time. I pasted the code below so that other people could benefit from it.

Thanks again! Albert-Jan

# in spssaux, modify the following function: def getShow(item): """Return the output for "item" as a string, where item is a SHOW command keyword.

Item must appear in the System Settings table. For the few items where there are multiple fields, the fields are separated with ";". An empty string will be returned for an invalid keyword. """

tag, ignore = createXmlOutput("SHOW " + item + ".", "SHOW")

# The xpath expression below is designed to work with all output languages result = ";".join(spss.EvaluateXPath(tag, '/', ## '//pivotTable[@subType="System Settings"]/dimension//category/dimension/category[2]/cell/@text')) # Old line '//pivotTable[@subType="File Handles"]/dimension/category/dimension/category/cell/@text')) # New line spss.DeleteXPathHandle(tag) return result # then save as e.g. spssaux_modified.py

# Call the sps syntax below in the custom button. BEGIN PROGRAM. """ Program to use Windows Explorer to open all active SPSS file handles. """ import subprocess, os.path import spssaux_modified as m

handles = m.getShow("handles").split(";") for handle in handles: if os.path.isdir(handle): subprocess.Popen("explorer " + handle) END PROGRAM.

--- On Mon, 7/20/09, Peck, Jon <peck@spss.com> wrote:

> From: Peck, Jon <peck@spss.com> > Subject: RE: [SPSSX-L] spssaux.getShow("handles") > To: "Albert-Jan Roskam" <fomcl@yahoo.com>, SPSSX-L@LISTSERV.UGA.EDU > Date: Monday, July 20, 2009, 3:46 PM > The getShow api only supports SHOW > entries in the System Settings table. In order to make > a version of getShow that would work with the File Handles > table, make a version of the GetShow function with the > following change. > > For the EvaluateXPath expression use > > //pivotTable[@subType="File > Handles"]/dimension/category/dimension/category/cell/@text > > That will select the File Handles table instead of the > System Settings table. The rest of the filter is > slightly different as well, since the structure of that > table is a little different from the System Settings table. > > With Version 18, coming shortly, there is a new api and a > new class named FileHandles in the spssaux module for > managing file handle creation, retrieval, and resolving > filespecs containing handles. > > Regards, > Jon Peck > > -----Original Message----- > From: SPSSX(r) Discussion [mailto:SPSSX-L@LISTSERV.UGA.EDU] > On Behalf Of Albert-Jan Roskam > Sent: Monday, July 20, 2009 6:06 AM > To: SPSSX-L@LISTSERV.UGA.EDU > Subject: [SPSSX-L] spssaux.getShow("handles") > > Hello, > > I have a simple Python question. I want to make a custom > menu button in spss dat activates a script that opens an > explorer screen for each directory that is defined in a FILE > HANDLE. The following code does not work, but it illustrates > what I want. In this case, it should open one explorer > instance that shows d:\temp. How can I make this work? > > import subprocess, os.path > import spss, spssaux > spss.Submit("file handle tmp /name = 'd:/temp'.") > for handle in spssaux.getShow("handles"): > if os.path.isdir(handle): > subprocess.Popen("explorer " + > handle) > > Thank you in advance for your time! > > Albert-Jan > > > --- On Sun, 7/19/09, Bruce Weaver <bweaver@lakeheadu.ca> > wrote: > > > From: Bruce Weaver <bweaver@lakeheadu.ca> > > Subject: Re: Variable Reordering > > To: SPSSX-L@LISTSERV.UGA.EDU > > Date: Sunday, July 19, 2009, 4:33 PM > > William Dudley WNDUDLEY wrote: > > > > > > Yes > > > You can easily reorder variables by opening the > file > > with a subset or new > > > order to the variables using the keep > command > > > > > > GET > > > FILE='C: \cargiver.sav' > > > /keep =ID PQUIETTM PGROUP > > PHOBBY PSOCIAL leisure_PART . > > > DATASET NAME $DataSet WINDOW=FRONT. > > > > > > And or you can open the files and then save as a > new > > file and use the keep > > > command to save a subset and or reorder the > > variables. > > > > > > SAVE OUTFILE='C:\new order caregiver.sav' > > > /keep =ID PQUIETTM PGROUP > > PHOBBY PSOCIAL leisure_PART > > > /COMPRESSED. > > > > > > > > > > Re the second method, rather than saving and then > re-opening the file, > > you can just use MATCH FILES (or ADD FILES), like > this: > > > > GET FILE='C:\new order caregiver.sav' . > > > > MATCH FILES > > file = * / > > keep =ID PQUIETTM PGROUP PHOBBY PSOCIAL > leisure_PART ALL . > > EXE. > > > > Note the keyword ALL at the end of the KEEP line. > > This will keep all other > > variables in their current order. > > > > > > ----- > > -- > > Bruce Weaver > > bweaver@lakeheadu.ca > > http://sites.google.com/a/lakeheadu.ca/bweaver/ > > "When all else fails, RTFM." > > > > -- > > View this message in context: > > http://www.nabble.com/Variable-Reordering-tp24557090p24557521.html > > Sent from the SPSSX Discussion mailing list archive at > Nabble.com. > > > > ===================== > > To manage your subscription to SPSSX-L, send a message > to > > LISTSERV@LISTSERV.UGA.EDU > (not to SPSSX-L), with no body text except > > the command. To leave the list, send the command > SIGNOFF SPSSX-L For a > > list of commands to manage subscriptions, send the > command INFO > > REFCARD > > > > ===================== > To manage your subscription to SPSSX-L, send a message to > LISTSERV@LISTSERV.UGA.EDU > (not to SPSSX-L), with no body text except the command. To > leave the list, send the command SIGNOFF SPSSX-L For a list > of commands to manage subscriptions, send the command INFO > REFCARD >

===================== To manage your subscription to SPSSX-L, send a message to LISTSERV@LISTSERV.UGA.EDU (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD


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