Hi Everyone, I’m adding all files in a directory for analysis and am doing this for different directories. Does anyone know of a shortcut for doing this? Here is how I have it set up now – please let me know if you have any suggestions. add files FILE='E:\teg2010\10084\DATA\RED\37207_1.sav' /FILE='E:\DATA\RED\37207_2.sav' /FILE='E:\DATA\RED\37207_3.sav' /FILE='E:\DATA\RED\37207_4.sav' /FILE='E:\DATA\RED\37207_5.sav' /FILE='E:\DATA\RED\37207_6.sav' /FILE='E:\DATA\RED\37207_7.sav' /FILE='E:\DATA\RED\37207_8.sav' /FILE='E:\DATA\RED\37207_9.sav' /FILE='E:\DATA\RED\37207_10.sav' /FILE='E:\DATA\RED\37207_11.sav' Thanks for any ideas, Jeanne |
Here's a solution.
begin program. import spss, glob allfiles = glob.glob("E:/DATA/RED/37207*.sav") filelist = ["/FILE='" + f + "'" for f in allfiles] cmd = r"ADD FILES add files FILE='E:\teg2010\10084\DATA\RED\37207_1.sav' " + "\n".join(filelist) spss.Submit(cmd) end program. The allfiles line finds all files matching the wildcard expression. The cmd line generates an add files command with the first file from a different location followed by the additional FILE subcommands. The spss.Submit line runs the command. This code assumes that there is at least 1 matching file and no more than 50 files altogether. Of course, this requires the Python programmability plugin. HTH, Jon Peck Senior Software Engineer, IBM [hidden email] 312-651-3435 From: Jeanne Eidex <[hidden email]> To: [hidden email] Date: 01/27/2011 08:29 AM Subject: [SPSSX-L] Adding All Files in A Directory: Shortcut? Sent by: "SPSSX(r) Discussion" <[hidden email]> Hi Everyone, I’m adding all files in a directory for analysis and am doing this for different directories. Does anyone know of a shortcut for doing this? Here is how I have it set up now – please let me know if you have any suggestions. add files FILE='E:\teg2010\10084\DATA\RED\37207_1.sav' /FILE='E:\DATA\RED\37207_2.sav' /FILE='E:\DATA\RED\37207_3.sav' /FILE='E:\DATA\RED\37207_4.sav' /FILE='E:\DATA\RED\37207_5.sav' /FILE='E:\DATA\RED\37207_6.sav' /FILE='E:\DATA\RED\37207_7.sav' /FILE='E:\DATA\RED\37207_8.sav' /FILE='E:\DATA\RED\37207_9.sav' /FILE='E:\DATA\RED\37207_10.sav' /FILE='E:\DATA\RED\37207_11.sav' Thanks for any ideas, Jeanne |
Administrator
|
In reply to this post by Jeanne Eidex
For some BP solutions (i.e., before Python), see items 1 & 2 here:
http://www.spsstools.net/SampleSyntax.htm#WorkingWithManyFiles HTH.
--
Bruce Weaver bweaver@lakeheadu.ca http://sites.google.com/a/lakeheadu.ca/bweaver/ "When all else fails, RTFM." PLEASE NOTE THE FOLLOWING: 1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above. 2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/). |
Free forum by Nabble | Edit this page |