databases and file handles

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

databases and file handles

Albert-Jan Roskam
Hi,

How can I make the code below work? (I would have sworn that this previously worked!). The point is that FILE HANDLES don't work in ODBC connect strings.
So I thought that the next best thing was to define a mini-macro for the database name and a file handle for the directory where the mdb lives. In any case, I only
want to use symbolical names after the file handles/macros have been defined.

file handle tempdir /name="%temp%".
define !database () "myDatabase.mdb" !enddefine.

cd tempdir.
*host commmand = ['cd /d %temp%'].
get data
  /type=odbc
  /connect='DSN=MS Access Database;DBQ=' + !database + ';DriverId=25;' +
   'FIL=MS Access;MaxBufferSize=2048;PageTimeout=5;;QuotedId=Yes'
  /sql='SELECT * FROM tblMyTable'
  /assumedstrwidth=255.
cache.
execute.

* this is an option, but it's ugly (despite of the fact that it's Python ;-)
begin program.
import spss
filehandles = {item[0]: item[1] for item in spss.GetFileHandles()}
spss.SetMacroValue("!path", "%r" % filehandles["tempdir"])
end program.
define !database () !path + "\myDatabase.mdb" !enddefine.
get data /
.....

Regards,
Albert-Jan


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
All right, but apart from the sanitation, the medicine, education, wine, public order, irrigation, roads, a
fresh water system, and public health, what have the Romans ever done for us?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

Importing Chinese Traditional Data Into SPSS v21 using UTF-8

Jarrod Teo-2
Hi,
 
I seems to have problem importing Chinese Characters into SPSS. I am using version 21. Please let me know what should I do because I keep getting gibberish character.
 
The weird thing is importing this CSV file into Excel using UTF-8, the traditional chinese characters were imported properly.
 
Any help will be appreciated.
 
Warmest Regards
Jarrod
Reply | Threaded
Open this post in threaded view
|

Re: Importing Chinese Traditional Data Into SPSS v21 using UTF-8

Jon K Peck
The interpretation of the input encoding depends on your locale setting, whether Statistics is in Unicode or code page mode, and whether or not there is a BOM (byte order mark) at the start of the file.

For a first step, check your locale (SHOW LOCALE).  If it is not traditional Chinese (Taiwan), set it to that with SET LOCALE.  What to do next depends on the actual encoding of the file, so report back on that.


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




From:        Jarrod Teo <[hidden email]>
To:        [hidden email],
Date:        07/10/2013 11:33 AM
Subject:        [SPSSX-L] Importing Chinese Traditional Data Into SPSS v21 using              UTF-8
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




Hi,

I seems to have problem importing Chinese Characters into SPSS. I am using version 21. Please let me know what should I do because I keep getting gibberish character.

The weird thing is importing this CSV file into Excel using UTF-8, the traditional chinese characters were imported properly.

Any help will be appreciated.

Warmest Regards
Jarrod