Popular recipes tagged "writer"http://code.activestate.com/recipes/tags/writer/2013-02-20T22:07:27-08:00ActiveState Code RecipesPython reader + writer for spss sav files (Linux, Mac & Windows) (Python) 2013-02-20T22:07:27-08:00Albert-Jan Roskamhttp://code.activestate.com/recipes/users/4177640/http://code.activestate.com/recipes/577811-python-reader-writer-for-spss-sav-files-linux-mac-/ <p style="color: grey"> Python recipe 577811 by <a href="/recipes/users/4177640/">Albert-Jan Roskam</a> (<a href="/recipes/tags/reader/">reader</a>, <a href="/recipes/tags/sav/">sav</a>, <a href="/recipes/tags/spss/">spss</a>, <a href="/recipes/tags/writer/">writer</a>). Revision 12. </p> <p><strong>Python Program to READ &amp; WRITE Spss system files (.sav) (Linux,Mac or Windows)</strong></p> <ul> <li><em>Check <a href="https://pypi.python.org/pypi/savReaderWriter/" rel="nofollow">https://pypi.python.org/pypi/savReaderWriter/</a> for the latest version (including the libraries!)</em></li> <li>Requires libspssdio.so.1 (LINUX) or libspssdio.dylib (MAC) or spssio32.dll (WINDOWS) plus associated libaries, which can be freely downloaded from: <a href="https://www.ibm.com/developerworks/mydeveloperworks/wikis/home/wiki/We70df3195ec8_4f95_9773_42e448fa9029/page/Downloads%2520for%2520IBM%25C2%25AE%2520SPSS%25C2%25AE%2520Statistics?lang=en" rel="nofollow">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</a></li> <li>It is recommended to download the v21 I/O files (required for writing zlib (.zsav) compressed files)</li> <li>December 2012 (complete rewrite):</li> <li>Added support for slicing, indexing, array slicing + other special methods</li> <li>Added support for writing spss date fields</li> <li>Added support for almost all meta data (missing values, sets, roles, etc.)</li> <li>Added support for 64 bit Windows (tested with Win7) and other OSs (z/Linux, Solaris, HP Linux, IBM AIX (untested though)</li> <li>Added support for reading and writing zlib compressed (.zsav) files</li> <li>Removed pesky segfault error when freeing memory</li> <li>Removed errors related to encoding</li> <li>Changed some Reader defaults (verbose=False, returnHeader=False)</li> <li>Renamed SavDataDictionaryReader into SavHeaderReader</li> </ul> <p><strong>LINUX:</strong></p> <p><em>Installation (tested on Linux Ubuntu 10):</em></p> <ul> <li>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.</li> <li>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.</li> <li>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.</li> </ul> <p><em>Calling the program:</em></p> <ul> <li>In the TERMINAL type: export LD_LIBRARY_PATH=/path/of/additional/sofiles; python /some/path/wrapperToProgram.py. You may also add ld_library_path to .bashrc</li> <li>The wrapper starts with "from SavReaderWriter import *", followed by e.g. stuff from the if __name__ == '__main__' section</li> </ul> <p><strong>MAC OS:</strong></p> <ul> <li>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</li> <li>one simple way to accomplish this is to copy them to /usr/lib</li> </ul> <p><strong>WINDOWS:</strong></p> <ul> <li>You can also find this dll in the installation directory of SPSS (although SPSS is _not_ needed!)</li> <li>The .dll should be saved in the same location as this program.</li> </ul> <p><strong>USAGE:</strong> See docstrings + __main__ section</p>