dont display output on insert or include file syntax

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

dont display output on insert or include file syntax

wsu_wright
Is there a subcommand option on the insert file or include file syntax to suppress the output.  Assuming one has checked for errors (which is possible in the errors=stop) it can be a bit much to have hundreds or thousands of lines of code displayed from the syntax used in the insert file.

Thanks in advance.

David

=====================
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: don't display output on insert or include file syntax

Peck, Jon
You can suppress any output using OMS.  Here is an example suppressing all LOGS from the Viewer.

oms select logs /destination viewer=no.
freq jobcat.
desc salary.

You could just put this in your INSERT/INCLUDE file.

You can also set output types to visible or not as a preference setting in Edit/Options/Viewer.

HTH,
Jon Peck

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of David Wright
Sent: Sunday, April 20, 2008 3:07 PM
To: [hidden email]
Subject: [SPSSX-L] dont display output on insert or include file syntax

Is there a subcommand option on the insert file or include file syntax to suppress the output.  Assuming one has checked for errors (which is possible in the errors=stop) it can be a bit much to have hundreds or thousands of lines of code displayed from the syntax used in the insert file.

Thanks in advance.

David

=====================
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
|

Python and File contention error "The save command has succeeded. However..."

K. Asselberghs
Is it possible - using Python - to check if a spss datafile has write access
before trying to save a file to that name?

This to prevent spss from saving the file under a different name.
SPSS message: "The SAVE command has succeeded. However, due to contention
for the specified file, the data have been saved to a different name".

The code might look something like this:

begin program.
import spss
datasetname='c:/temp/ev.sav'
# check here with python code if the file has write access (is not locked
for writing by the operating system).
# if not, raise an error and stop spss syntax execution, else save the file
and continue.
spss.Submit(r"""
preserve.
set printback on mprint on.
save outfile='%(datasetname)s'.
restore.
    """ %locals())
end program.



=====================
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: Python and File contention error "The save command has succeeded. However..."

Art Kendall
Bypassing this safety feature should only be done with extreme care.

I start with the view that an analysis goes through several rounds of
refinement. Unless you used python to rename the old version before
writing a new version  you would be in danger of burning your bridges
and be unable to revise your whole approach.  You might also end up
"shredding" your data.

Although there are rare occasions where you want to write over the same
file, such a thing should be deliberate enough that you do so explicitly.

Art Kendall
Social Research Consultants

Karel Asselberghs wrote:

> Is it possible - using Python - to check if a spss datafile has write access
> before trying to save a file to that name?
>
> This to prevent spss from saving the file under a different name.
> SPSS message: "The SAVE command has succeeded. However, due to contention
> for the specified file, the data have been saved to a different name".
>
> The code might look something like this:
>
> begin program.
> import spss
> datasetname='c:/temp/ev.sav'
> # check here with python code if the file has write access (is not locked
> for writing by the operating system).
> # if not, raise an error and stop spss syntax execution, else save the file
> and continue.
> spss.Submit(r"""
> preserve.
> set printback on mprint on.
> save outfile='%(datasetname)s'.
> restore.
>     """ %locals())
> end program.
>
>
>
> =====================
> 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
>
>
>

=====================
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
Art Kendall
Social Research Consultants
Reply | Threaded
Open this post in threaded view
|

Re: Python and File contention error "The save command has succeeded. However..."

Peck, Jon
In reply to this post by K. Asselberghs
There are two different issues here.
The first one is whether the sav file is marked read only in the file system, in which case, SPSS would not overwrite it.

This can be easily checked with Python code.
import os
if os.access("c:/temp/target.sav", os.W_OK):
        print "writeable"
else:
        print "not writeable"

The second issue is: is the file currently opened for exclusive access by SPSS or some other program.  I'm not sure that the following will cover all cases, but you could try something like this.

try:
  f=open("c:/temp/target.sav","r+")
  f.close()
except:
  print "file is currently in use"

This case includes the first.  The open call will fail if the file is read only or if it is in use.

HTH,
Jon Peck


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Karel Asselberghs
Sent: Wednesday, April 23, 2008 3:48 AM
To: [hidden email]
Subject: [SPSSX-L] Python and File contention error "The save command has succeeded. However..."

Is it possible - using Python - to check if a spss datafile has write access
before trying to save a file to that name?

This to prevent spss from saving the file under a different name.
SPSS message: "The SAVE command has succeeded. However, due to contention
for the specified file, the data have been saved to a different name".

The code might look something like this:

begin program.
import spss
datasetname='c:/temp/ev.sav'
# check here with python code if the file has write access (is not locked
for writing by the operating system).
# if not, raise an error and stop spss syntax execution, else save the file
and continue.
spss.Submit(r"""
preserve.
set printback on mprint on.
save outfile='%(datasetname)s'.
restore.
    """ %locals())
end program.



=====================
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

=====================
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: Python and File contention error "The save command has succeeded. However..."

K. Asselberghs
Art, John, thank you for your comments!

I agree with Art that it's important always to be able to reproduce or
revise an analysis. But that can be done by keeping copies of the original
data files and the syntax files. I would rather not have many versions of
the same datafile on disk.

John's solution works fine, but cannot be used to prevent file contention if
you want to save the active file under the same name, because the file is in
use by spss itself.

I would much prefer spss to generate an error and stop syntax execution in
case of file contention, or at least leave it up to the user what to do in
that case, instead of just saving the file under another name and running
on.


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Peck, Jon
Sent: woensdag 23 april 2008 17:15
To: [hidden email]
Subject: Re: Python and File contention error "The save command has
succeeded. However..."

There are two different issues here.
The first one is whether the sav file is marked read only in the file
system, in which case, SPSS would not overwrite it.

This can be easily checked with Python code.
import os
if os.access("c:/temp/target.sav", os.W_OK):
        print "writeable"
else:
        print "not writeable"

The second issue is: is the file currently opened for exclusive access by
SPSS or some other program.  I'm not sure that the following will cover all
cases, but you could try something like this.

try:
  f=open("c:/temp/target.sav","r+")
  f.close()
except:
  print "file is currently in use"

This case includes the first.  The open call will fail if the file is read
only or if it is in use.

HTH,
Jon Peck


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Karel Asselberghs
Sent: Wednesday, April 23, 2008 3:48 AM
To: [hidden email]
Subject: [SPSSX-L] Python and File contention error "The save command has
succeeded. However..."

Is it possible - using Python - to check if a spss datafile has write access
before trying to save a file to that name?

This to prevent spss from saving the file under a different name.
SPSS message: "The SAVE command has succeeded. However, due to contention
for the specified file, the data have been saved to a different name".

The code might look something like this:

begin program.
import spss
datasetname='c:/temp/ev.sav'
# check here with python code if the file has write access (is not locked
for writing by the operating system).
# if not, raise an error and stop spss syntax execution, else save the file
and continue.
spss.Submit(r"""
preserve.
set printback on mprint on.
save outfile='%(datasetname)s'.
restore.
    """ %locals())
end program.



=====================
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

=====================
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: Python and File contention error "The save command has succeeded. However..."

Albert-Jan Roskam
In reply to this post by Art Kendall
I agree with you Art, I always put the file attribute
of source files on read only. Or I use a syntax like
the one below. Intermediate files are a different
story. Here Jon's solution might come in handy.

Also, with older Windows versions, a file sometimes
cannot be written over, whereas it's not in use
(anymore) by any program. Very annoying. While the
Python script doesn't solve this, it at least makes
sure further processing is cancelled.

Cheers,
Albert-Jan

file handle orig_file /name = 'd:\my
documents\my_original_source_file.sav'.
get file = orig_file.
permissions file = orig_file /permissions readonly.


--- Art Kendall <[hidden email]> wrote:

> Bypassing this safety feature should only be done
> with extreme care.
>
> I start with the view that an analysis goes through
> several rounds of
> refinement. Unless you used python to rename the old
> version before
> writing a new version  you would be in danger of
> burning your bridges
> and be unable to revise your whole approach.  You
> might also end up
> "shredding" your data.
>
> Although there are rare occasions where you want to
> write over the same
> file, such a thing should be deliberate enough that
> you do so explicitly.
>
> Art Kendall
> Social Research Consultants
>
> Karel Asselberghs wrote:
> > Is it possible - using Python - to check if a spss
> datafile has write access
> > before trying to save a file to that name?
> >
> > This to prevent spss from saving the file under a
> different name.
> > SPSS message: "The SAVE command has succeeded.
> However, due to contention
> > for the specified file, the data have been saved
> to a different name".
> >
> > The code might look something like this:
> >
> > begin program.
> > import spss
> > datasetname='c:/temp/ev.sav'
> > # check here with python code if the file has
> write access (is not locked
> > for writing by the operating system).
> > # if not, raise an error and stop spss syntax
> execution, else save the file
> > and continue.
> > spss.Submit(r"""
> > preserve.
> > set printback on mprint on.
> > save outfile='%(datasetname)s'.
> > restore.
> >     """ %locals())
> > end program.
> >
> >
> >
> > =====================
> > 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
> >
> >
> >
>
> =====================
> 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
>



      ____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ

=====================
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: Python and File contention error "The save command has succeeded. However..."

K. Asselberghs
One remark.

Further processing is NOT cancelled by the python script.
SPSS will continue processing syntax after execution of a python script.
SPSS can only be stopped when run from python (with spss.StopSPSS).



-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Albert-jan Roskam
Sent: donderdag 24 april 2008 11:33
To: [hidden email]
Subject: Re: Python and File contention error "The save command has
succeeded. However..."

I agree with you Art, I always put the file attribute
of source files on read only. Or I use a syntax like
the one below. Intermediate files are a different
story. Here Jon's solution might come in handy.

Also, with older Windows versions, a file sometimes
cannot be written over, whereas it's not in use
(anymore) by any program. Very annoying. While the
Python script doesn't solve this, it at least makes
sure further processing is cancelled.

Cheers,
Albert-Jan

file handle orig_file /name = 'd:\my
documents\my_original_source_file.sav'.
get file = orig_file.
permissions file = orig_file /permissions readonly.


--- Art Kendall <[hidden email]> wrote:

> Bypassing this safety feature should only be done
> with extreme care.
>
> I start with the view that an analysis goes through
> several rounds of
> refinement. Unless you used python to rename the old
> version before
> writing a new version  you would be in danger of
> burning your bridges
> and be unable to revise your whole approach.  You
> might also end up
> "shredding" your data.
>
> Although there are rare occasions where you want to
> write over the same
> file, such a thing should be deliberate enough that
> you do so explicitly.
>
> Art Kendall
> Social Research Consultants
>
> Karel Asselberghs wrote:
> > Is it possible - using Python - to check if a spss
> datafile has write access
> > before trying to save a file to that name?
> >
> > This to prevent spss from saving the file under a
> different name.
> > SPSS message: "The SAVE command has succeeded.
> However, due to contention
> > for the specified file, the data have been saved
> to a different name".
> >
> > The code might look something like this:
> >
> > begin program.
> > import spss
> > datasetname='c:/temp/ev.sav'
> > # check here with python code if the file has
> write access (is not locked
> > for writing by the operating system).
> > # if not, raise an error and stop spss syntax
> execution, else save the file
> > and continue.
> > spss.Submit(r"""
> > preserve.
> > set printback on mprint on.
> > save outfile='%(datasetname)s'.
> > restore.
> >     """ %locals())
> > end program.
> >
> >
> >
> > =====================
> > 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
> >
> >
> >
>
> =====================
> 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
>




____________________________________________________________________________
________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile.  Try it now.
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ

=====================
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