add file

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

add file

drfg2008
we need to add big amount of files. The ADD FILE command only accepts max 50 files (as far as I am informed). Therefor we use a solution like:

begin program.
import spss

spss.Submit(r"""
GET  FILE='E:\\<path>_www1_1.sav'.
                DATASET NAME ActiveSet WINDOW=FRONT.
                """)
               
for n in xrange(1,len(dates)+1):
        for t in xrange(1,onlineDB+1):
                everyConnDelta="www"+str(t)+"_"+str(n)
                print everyConnDelta
                if everyConnDelta=="www1_1":
                        continue
         spss.Submit(r"""
                                ADD FILES  /FILE = *
                                /FILE = 'E:\\<path>_"""+everyConnDelta+""".sav'.
                                EXECUTE.
          """)
end program.



But that takes long, since every file has to be added separately. Is there any faster (and RAM sensitive) solution?

Thx.
Dr. Frank Gaeth

Reply | Threaded
Open this post in threaded view
|

Re: add file

David Marso
Administrator

Quite obviously Frank, remove the EXECUTE!!
Also maybe add 50 at a time rather than 1?
--
drfg2008 wrote
we need to add big amount of files. The ADD FILE command only accepts max 50 files (as far as I am informed). Therefor we use a solution like:

begin program.
import spss

spss.Submit(r"""
GET  FILE='E:\\<path>_www1_1.sav'.
                DATASET NAME ActiveSet WINDOW=FRONT.
                """)
               
for n in xrange(1,len(dates)+1):
        for t in xrange(1,onlineDB+1):
                everyConnDelta="www"+str(t)+"_"+str(n)
                print everyConnDelta
                if everyConnDelta=="www1_1":
                        continue
         spss.Submit(r"""
                                ADD FILES  /FILE = *
                                /FILE = 'E:\\<path>_"""+everyConnDelta+""".sav'.
                                EXECUTE.
          """)
end program.



But that takes long, since every file has to be added separately. Is there any faster (and RAM sensitive) solution?

Thx.
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: add file

Jon K Peck
In reply to this post by drfg2008
Here is some code I wrote some time ago to merge large  numbers of sav files without enumerating the names.

* join all the sav files in a directory using ADD FILES in batches.
begin program.
import spss, glob

filelist = glob.glob("c:/mysavfiles/*.sav")
spss.Submit(r"""get file="%s".
dataset name first.""" % filelist[0])

for f in range(1, len(filelist), 49):
   cmd = ["ADD FILES /FILE=*"]
   cmd.extend(["""/FILE="%s" """ % item for item in filelist[f: min(f+49, len(filelist))]])
   spss.Submit("‎\‏n".join(cmd) + ".")
end program.

DATASET ACTIVATE first.
SAVE OUTFILE="c:/mysavfiels/altogether.sav".


Jon Peck (no "h") aka Kim
Senior Software Engineer, IBM
[hidden email]
phone: 720-342-5621




From:        drfg2008 <[hidden email]>
To:        [hidden email]
Date:        01/23/2015 03:32 AM
Subject:        [SPSSX-L] add file
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




we need to add big amount of files. The ADD FILE command only accepts max 50
files (as far as I am informed). Therefor we use a solution like:

/begin program.
import spss

spss.Submit(r"""
GET  FILE='E:\\<path>_www1_1.sav'.
                                 DATASET NAME ActiveSet WINDOW=FRONT.
                                 """)
                                 
for n in xrange(1,len(dates)+1):
                for t in xrange(1,onlineDB+1):
                                 everyConnDelta="www"+str(t)+"_"+str(n)
                                 print everyConnDelta
                                 if everyConnDelta=="www1_1":
                                                  continue
                 spss.Submit(r"""
                                                                   ADD FILES  /FILE = *
                                                                   /FILE = 'E:\\<path>_"""+everyConnDelta+""".sav'.
                                                                   EXECUTE.
                  """)
end program./


But that takes long, since every file has to be added separately. Is there
any faster (and RAM sensitive) solution?

Thx.




-----
Dr. Frank Gaeth


--
View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/add-file-tp5728459.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (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 [hidden email] (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
Reply | Threaded
Open this post in threaded view
|

Re: add file

drfg2008
thx a lot!

F.
Dr. Frank Gaeth