File path names

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

File path names

Ron0z
Some of the path names to the location of data I use can be very long, and
certainly file handles can tidy that up.  However, sometimes it’s convenient
to dispense with the file handle approach; perhaps during code development.
When the command file and data reside at the same location using the full
path is tedious, but necessary.  Is there a way to avoid it?

For example, in the following code snippet, the complete path as shown in
the example is required for the code to function correctly:
GET DATA /TYPE=XLSX
  /FILE='I:\CORS\COMMON\Statistics Unit\PLANNING\POLICY\STATS\2018\HEP
Reporting\DET Complaints 2018\6\*201806 Provider Payment Report (8) - SPSS
Copy.xlsx'*

But this will not work despite both the data and command file being in the
same location:
GET DATA /TYPE=XLSX
  /FILE=*'201806 Provider Payment Report (8) - SPSS Copy.xlsx'*
Error.  Command name: GET DATA
(2052) Error accessing the Excel file






--
Sent from: http://spssx-discussion.1045642.n5.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
Reply | Threaded
Open this post in threaded view
|

Re: File path names

Rick Oliver
You can use the CD command to change the current directory for both data and syntax files.  If you are looking for a way to tell the application that data files are in the same location as the the syntax file that contains commands to get those data files (or in a location relative to the syntax file), I don't think there is an out-of-the-box solution for that. There might be an extension command that does something like that, although I'm not sure how that would work when running interactively. 

On Mon, Aug 20, 2018 at 8:29 PM Ron0z <[hidden email]> wrote:
Some of the path names to the location of data I use can be very long, and
certainly file handles can tidy that up.  However, sometimes it’s convenient
to dispense with the file handle approach; perhaps during code development.
When the command file and data reside at the same location using the full
path is tedious, but necessary.  Is there a way to avoid it?

For example, in the following code snippet, the complete path as shown in
the example is required for the code to function correctly:
GET DATA /TYPE=XLSX
  /FILE='I:\CORS\COMMON\Statistics Unit\PLANNING\POLICY\STATS\2018\HEP
Reporting\DET Complaints 2018\6\*201806 Provider Payment Report (8) - SPSS
Copy.xlsx'*

But this will not work despite both the data and command file being in the
same location:
GET DATA /TYPE=XLSX
  /FILE=*'201806 Provider Payment Report (8) - SPSS Copy.xlsx'*
Error.  Command name: GET DATA
(2052) Error accessing the Excel file






--
Sent from: http://spssx-discussion.1045642.n5.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: File path names

Jon Peck
A few tips:
The file handle does not have to be the complete path.  You could set it to as much of the beginning of the full path as is convenient and reference it and complete it when you specify a file.

The INSERT command has an optional CD parameter that changes the backend working directory to the file path in the FILE keyword of INSERT.  That tells the backend where to look by default for data files (or other INSERTs).

The STATS OPEN PROJECT extension command can be used to set up a project environment, including setting directories and file handles, running syntax files, defining macros, and opening data and syntax files.  Projects can open other projects, so you could have, for example, a standard set of tools and configurations that you always want at startup and then have specific settings for particular projects.  It can be set to run automatically when Statistics is launched or by running it explicitly.  It appears as File > Open > Project once it is installed.  It can be installed from the Extensions or Utilities menu depending on your Statistics version.

A little more esoteric is the STATS FIND FILE extension command.  It defines a file handle for the folder where the first instance of the specified file or wildcard is found.  So it searches a wildcard list of folders, optionally including subfolders and/or environment variables and defines a file handle pointing to the first location where the file is found.  Here is an example.  
STATS FIND FILE FILENAME="employee data.*" FILEHANDLE=employee FOLDERLIST="c:/spss/samples/english;c:/data".  

That would look in the specified folders, which could include a wildcard, and define the handle employee whose value is the folder where the file was found.  Press F1 on an instance in the Syntax Editor for the full help (as with other extension commands).

On Mon, Aug 20, 2018 at 8:08 PM Rick Oliver <[hidden email]> wrote:
You can use the CD command to change the current directory for both data and syntax files.  If you are looking for a way to tell the application that data files are in the same location as the the syntax file that contains commands to get those data files (or in a location relative to the syntax file), I don't think there is an out-of-the-box solution for that. There might be an extension command that does something like that, although I'm not sure how that would work when running interactively. 

On Mon, Aug 20, 2018 at 8:29 PM Ron0z <[hidden email]> wrote:
Some of the path names to the location of data I use can be very long, and
certainly file handles can tidy that up.  However, sometimes it’s convenient
to dispense with the file handle approach; perhaps during code development.
When the command file and data reside at the same location using the full
path is tedious, but necessary.  Is there a way to avoid it?

For example, in the following code snippet, the complete path as shown in
the example is required for the code to function correctly:
GET DATA /TYPE=XLSX
  /FILE='I:\CORS\COMMON\Statistics Unit\PLANNING\POLICY\STATS\2018\HEP
Reporting\DET Complaints 2018\6\*201806 Provider Payment Report (8) - SPSS
Copy.xlsx'*

But this will not work despite both the data and command file being in the
same location:
GET DATA /TYPE=XLSX
  /FILE=*'201806 Provider Payment Report (8) - SPSS Copy.xlsx'*
Error.  Command name: GET DATA
(2052) Error accessing the Excel file






--
Sent from: http://spssx-discussion.1045642.n5.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


--
Jon K Peck
[hidden email]

===================== 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: File path names

Ron0z
Well, thank you. I have some experimenting to do. Much obliged!



--
Sent from: http://spssx-discussion.1045642.n5.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