[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: what essential GUI pieces are left?

From: Ben Pfaff
Subject: Re: what essential GUI pieces are left?
Date: Mon, 31 Mar 2008 21:57:47 -0700
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux)

John Darrington <address@hidden> writes:

> On Mon, Mar 31, 2008 at 02:07:38PM -0700, Ben Pfaff wrote:
>      What would the opposite of GET DATA be?  "PUT DATA" perhaps?
> To be orthogonal(ish) with the rest of the language, shouldn't it  be

You're right.  That sounds better too.

> However, I wonder how wise it is to start adding our own commands to
> the language in an ad hoc manner.  Adding subcommands to existing
> commands is one thing, but complete new commands is another.

It's hard for me to imagine what harm would befall us in adding
new commands to the language.  The only likely scenario I can
foresee is that we add a command name that is also added later by
SPSS with differing semantics.  I am not too worried about this.
Are you?  Or do you have a different problem in mind?

The issue, I think, is this: it's useful to add CSV export to the
GUI.  This is somewhat tricky (see below) to do in syntax.  So
should the GUI do it by emitting a new command that we define, or
by just running some code that is not exposed to syntax users?
The former is strictly more useful than the latter, in my

> When I want to do this, I use a syntax similar to 
> DATA LIST LIST /x (a12)  y *.
> One 1
> Two 2
> Three 3
> PRINT OUTFILE='foo.txt'
>         /x (A12) y (F7).

The main trouble with this is delimiters.  If space is the field
delimiter (which is implied to be the case here), then any field
with a space will be parsed as two fields.  You can avoid using a
comma as the field delimiter instead, like so:

    PRINT OUTFILE='foo.txt'
            /x (A12) ',' y (F7).

Then if variable x contains a comma, it will cause trouble.  You
can avoid that problem, in turn, by adding quotes:

    PRINT OUTFILE='foo.txt'
            /'"' x (A12) '",' y (F7).

Now a problem arises if x can contain quote marks.  GET DATA can
handle them on input if we double them, and some other
applications understand the same form of escapes.  So then we
end up with:

    string #x (a24).
    compute #x = replace(x, '"', '"").
    PRINT OUTFILE='foo.txt'
            /'"' #x (A24) '",' y (F7).

which doesn't actually work because the replace function is new
in SPSS 16 and we haven't implemented it yet, but it would.

It all seems like a bit much to expect from casual users who just
want to export to CSV format.
Ben Pfaff

reply via email to

[Prev in Thread] Current Thread [Next in Thread]