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 (May 2008)Back to main SPSSX-L pageJoin or leave SPSSX-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 20 May 2008 06:00:15 -0700
Reply-To:     maiya <maja.zaloznik@GMAIL.COM>
Sender:       "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From:         maiya <maja.zaloznik@GMAIL.COM>
Subject:      Re: save translate to existing file name?
In-Reply-To:  <879f8ec00805191555g1323c01fpe3ad3e4c75d2a8a2@mail.gmail.com>
Content-Type: text/plain; charset=us-ascii

Thanks Rayland!

Unfortunatley I have never worked with python, and was really hoping this can be done through regular spss syntax. The whole reason for my wish to batch translate these files is becasue I'm switching my analysis to R, and hopefuly never looking back. So can I do this using just syntax? Thanks again!

Maja

Raynald Levesque-2 wrote: > > Hi > > Here is a python solution. > > All you need to do is replace "C:/Program Files/SPSS/" (in the last line > of > the PROGRAM block) by the path of your folder. > The *.dat files are saved in the same folder as the existing sav files. > > Regards > > -- > Raynald Levesque > www.spsstools.net > > > BEGIN PROGRAM. > #convert all sav files into tab delimited file > import spss, glob, os.path > > def exportToDat(folder): > savlist = glob.glob(folder) > nbConverted = 0 > for fname in savlist: > stem=os.path.basename(fname) > fpath=os.path.abspath(fname) > spss.Submit(""" > GET FILE='%(fname)s'. > SAVE TRANSLATE OUTFILE='%(fpath)s%(stem)s.dat' > /TYPE=TAB /MAP /REPLACE /FIELDNAMES > /CELLS=VALUES. """ % locals()) > nbConverted += 1 > > print "Number of sav files converted:", nbConverted > exportToDat(folder=r"C:/Program Files/SPSS/*.sav") > END PROGRAM. > > On Mon, May 19, 2008 at 5:07 PM, maiya <maja.zaloznik@gmail.com> wrote: > >> Hi, I'm wondering how i would go about converting a series of .sav files >> into >> .dat files, while keeping their same names as they are. I hope this is >> clear: I wan't to loop a save translate command through a whole folder, >> set >> type to tab, and somehow have the outfile i.e. new name be generated >> automatically from the old name - but of course with the new extension. >> so >> eqS40n5cat.sav -> eqS40n5cat.dat >> eqS40n6cat.sav -> eqS40n6cat.dat >> eqS40n7cat.sav -> eqS40n7cat.dat >> etc. >> so the question is how to refer to the file's name in syntax? >> thanks guys! >> maja >> -- >> View this message in context: >> http://www.nabble.com/save-translate-to-existing-file-name--tp17328219p17328219.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 > >

-- View this message in context: http://www.nabble.com/save-translate-to-existing-file-name--tp17328219p17339730.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


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