Exporting to SPSS files in Python Django?

2019-02-26 21:51发布

问题:

i need to export data to SPSS file format in Python (Django), but i can't find util information in google.

Is there some way to do this? Someone has tried?

thanks in advance!

回答1:

The savReaderWriter package can be used to read or write SPSS files (.sav, zsav), including metadata: https://pypi.python.org/pypi/savReaderWriter/3.1.2



回答2:

As far as I am aware, the only API provided by IBM to interact with SPSS is designed to be used in C/C++.

You will have to look up the appropriate SPSS developer's guide for your version of SPSS and download the required files from their website.

That being said, I know you can load a DLL and use it from within Python with ctypes (See this question).

Once you have the API, you can easily read/write/create SPSS database files. I am not sure there are any Django plugins that provide this functionality, but you might be able to write your own. Additionally using ctypes somewhere in your view directly might be a quicker way to do it.

Also, I know later versions of SPSS have Python scripting support but I don't think that could come in handy at all.

EDIT

Here is a list of resources that might be useful for different versions of SPSS:

it turns out all versions after 14.0 use the same API, so I fixed the links to reflect that. Apparently they host a different copy of the file with each version.

  • Developer's Guide (Pdf)
  • Headers, DLL & Docs (Zip)