SPSS Statistics

Expand all | Collapse all

[PYTHON] Cursor and Dataset - difference

  • 1.  [PYTHON] Cursor and Dataset - difference

    Posted Wed October 14, 2020 07:53 AM

    Hello, I have a huge, complicated dataset which I need to transform using a Python plug-in. I read in a Python Reference Guide and noticed there are in fact two classes providing an access to a dataset cases'/variables' values – spss.Cursor and spss.Dataset. Both of them look pretty similar for me but I don't know what are the main differences between (hence – advantages/disadvantages). I would be very grateful if anyone briefly explained it to me. Thanks!



  • 2.  RE: [PYTHON] Cursor and Dataset - difference

    Posted Wed October 14, 2020 08:42 AM
    The Cursor class is best used through the spssdata module, which provides a lot of convenience features wrapped around the Cursor class.  spssdata is installed with the plugin, but you need to look at the docstrings in the module for usage instructions.

    The Dataset class has some functionality not available in the other classes, especially when it comes to creating new variables or datasets and random access, but it is much slower than the other modules.  I suggest that if the spssdata functionality is sufficient, you should use that; otherwise use the Dataset code.

    --





  • 3.  RE: [PYTHON] Cursor and Dataset - difference

    Posted Wed October 14, 2020 08:56 AM

    Hello John, thanks for your answer! I can't find 'spssdata' in a reference. Did you mean spss.DataStep or spss.DataDoc?

     

    Regarding a difference between Cursor and Dataset – I guess you recommend the first one due to efficiency reasons, right?






  • 4.  RE: [PYTHON] Cursor and Dataset - difference

    Posted Wed October 14, 2020 09:09 AM
    No.  The spssdata classes and methods are documented only in docstring comments in the spssdata.py module.  The place to start would be the Spssdata class.  You can find that module in the python\lib\site-packages\spssdata folder under your Statistics installation (or the Python3 equivalent).  Those methods are heavily used in most of the extension commands implemented in Python.

    --