selectVars doesn't work

Issue #18 resolved
Former user created an issue

using selectVars has no effect; it does not create a selection of the variables in the file

savReader 3.3.0

from savReaderWriter import SavReader savfile = "employee data.sav" employee_sav = SavReader(savfile) selection = SavReader(savfile, selectVars=['gender', 'jobcat']) employee_sav.varNames selection.varNames selection == employee_sav

Comments (2)

  1. Albert-Jan Roskam repo owner

    Hi,

    The code below works in Python 2 and 3 (Debian Linux x86-64). I did discover, however, a bug when a selection of just one variable is made (.e.g selectVars=['id']).

    It was never my intention to let the selectVars setting propagate to all the meta data properties of the Header class (e.g varLabels, valueLabels, etc. etc.). It was supposed to speed up SavReader a little.

    from savReaderWriter import SavReader
    
    savFileName = '/usr/local/lib/python2.7/dist-packages/savReaderWriter/test_data/Employee data.sav'
    with SavReader(savFileName, selectVars=[b'id', b'educ'], returnHeader=True) as reader:
        for line in reader:
            print(line)
    
  2. Log in to comment