Python reader + writer for spss sav files (Linux, Mac & Windows)

5 Rating of Python reader + writer for spss sav files (Linux, Mac & Windows)

Category: Python - Miscellaneous

Python Program to READ & WRITE Spss system files (.sav) (Linux,Mac or Windows)


Requires libspssdio.so.1 (LINUX) or libspssdio.dylib (MAC) or spssio32.dll (WINDOWS) plus associated libaries, which can be freely downloaded from:
https://www.ibm.com/developerworks/mydeveloperworks/wikis/home/wiki/We70df3195ec8_4f95_9773_42e448fa9029/page/Downloads%20for%20IBM%C2%AE%20SPSS%C2%AE%20Statistics?lang=en


LINUX:

Installation (tested on Linux Ubuntu 10):


additional packages/files needed are: intel-icc8-libs_8.0-1_i386.deb,libicu32_3.2-3_i386.deb, libstdc++5_3.3.6-20_i386.deb, libirc.so.
Run the following commands in your terminal: sudo apt-get install intel-icc8-libs; sudo apt-get install libicu32; sudo apt-get install libstdc++5.
Then convert libirc.a (static) to libirc.so (dynamic), save in same location as libspssdio.so.1:
ar vx intel-icc8-libs_8.0-1_i386.deb; tar -xzvf data.tar.gz ./usr/lib/libirc.a; ar -x libirc.a.


Calling the program:


In the TERMINAL type: export LD_LIBRARY_PATH=/path/of/additional/sofiles; python /some/path/wrapperToProgram.py
The wrapper starts with "from SavReaderWriter import *", followed by e.g. stuff from the if __name__ == '__main__' section


MAC OS:


you must put all the dylib files that come with the IBM
SPSS_Statistics_InputOutput_Modules_* package in the macos
directory somewhere that OS X can find them
one simple way to accomplish this is to copy them to /usr/lib


WINDOWS:


You can also find this dll in the installation directory of SPSS (although SPSS is _not_ needed!)
The .dll should be saved in the same location as this program.


USAGE:


READER -- Parameters:
savFileName: the file name of the spss data file;
returnHeader: Boolean that indicates whether the first record
should be a list of variable names (default: True);
recodeSysmisTo: indicates to which value missing values should
be recoded (default: "");
selectVars: indicates which variables in the file should be
selected.The variables should be specified as a list or a tuple
of valid variable names. If None is specified, all variables
in the file are used (default: None);
verbose: Boolean that indicates whether information about the
spss data file (e.g., number of cases, variable names, file
size) should be printed on the screen (default:
True).
rawMode: Boolean that indicates whether values should get
SPSS-style formatting,and whether date variables (if present)
should be converted to ISO-dates. If True, the program does not
format any values, which increases processing speed. (default:
= False)
interfaceEncoding Indicates the mode in which text communicated
to or from the I/O Module will be. Valid values are 'UTF-8' or
'CODEPAGE' (default = 'CODEPAGE')
Typical use:
savFileName = "d:/someFile.sav"
with SavReader(savFileName) as sav:
header = sav.next()
for line in sav:
process(line)



WRITER -- Parameters:
savFileName: the file name of the spss data file
varNames: list or a tuple with the variable names of the spss data file.
varTypes: varTypes dictionary {varName: varType}, where VarType == 0 means 'numeric', and varType > 0 means 'character' of that length
printTypesFile: optional printType dictionary {varName: spssFmt} (default: None)
varLabels: optional variable label dictionary {varName: varLabel} (default: None)
valueLabels: optional value label dictionary {varName: {value: label}} (default: None)
overwrite: Boolean that indicates whether an existing Spss file should be overwritten (default: True)
SAVDATADICTIONARYREADER -- Parameters:
savFileName: the file name of the spss data file
Example use:
with SavDataDictionaryReader(savFileName) as spssDict:
for varName in spssDict.varNames:
print spssDict.getValueLabels(varName)[1]
print spssDict.getVarLabel(varName)[1]
wholeDict = spssDict.dataDictionary()
print wholeDict.keys()
spssDict.reportSpssDataDictionary(wholeDict) Date: 27 February, 2012


Reader - Sav - Spss - Writer

Homepage: http://code.activestate.com/recipes/577811-python-reader-writer-for-spss-sav-files-linux-mac-/?in=lang-python

Developer: Albert-Jan Roskam

License: Freeware

Operating System: Windows

Add a Comment

all are required fields

     
What do you think of this resource?

Current User Rating: 5 Stars

Select Your Rate:

Votes:2

 

Related Scripts Download

Add the latest news, from almost any news feed or news server in the world, directly into your own website.

developer Developer: neomyz.com
license License: Freeware
operating systems Operating System: Linux, Unix, Windows


FreeGuestbookHost offers free hosted guestbooks with features including: PHP Based Guestbook, Ultra Fast Servers, Custom Table / Font Colors, Custom Background Color, Custom Guestbook Description, Custom Guestbook Logo, Delete Unwanted Entries.

developer Developer: freeguestbookhost.com
license License: Freeware
operating systems Operating System: All


Create a free guestbook for your web site today and customize it to match your existing site's layout.

developer Developer: Nav2.net
license License: Freeware
operating systems Operating System: ALL


Ishmail is a graphical mail reader for Unix systems.

developer Developer: SourceForge.net
license License: Freeware
operating systems Operating System: All


In this script the reader iterates over records in Dbase or Xbase files and the writer creates dbf files from Python sequences.

developer Developer: code.activestate.com
license License: Freeware
operating systems Operating System: All


Ext/id3 is an extension for PHP that is written in C.

developer Developer: pecl.php.net
license License: Freeware
operating systems Operating System: All


Story Time is a Java based Book Reader similar to that of a children's CD-ROM Book.

developer Developer: SourceForge.net
license License: Freeware
operating systems Operating System: All


The only catch is that the function has to return locals() at the end.

developer Developer: Eric Snow
license License: Freeware
operating systems Operating System: Windows


This small program lets a user delete a directory on their Windows system.

developer Developer: Acheev Bhagat
license License: Freeware
operating systems Operating System: Windows