Source

savReaderWriter / savReaderWriter / doc_tests / test_SavHeaderReader_dictionary.txt

##############################################################################
## Print a Python dictionary of the SPSS dictionary (aka header information)
##############################################################################

>>> import sys
>>> sys.stdout.write('<skipline> '); from savReaderWriter import * # doctest: +ELLIPSIS
<skipline> ...

>>> savFileName = "../savReaderWriter/test_data/Employee data.sav"
>>> with SavHeaderReader(savFileName) as spssDict: # doctest: +ELLIPSIS
...     wholeDict = spssDict.dataDictionary()
>>> desired = \
...     {'alignments': {'bdate': 'right',
...                     'educ': 'right',
...                     'gender': 'left',
...                     'id': 'right',
...                     'jobcat': 'right',
...                     'jobtime': 'right',
...                     'minority': 'right',
...                     'prevexp': 'right',
...                     'salary': 'right',
...                     'salbegin': 'right'},
...      'caseWeightVar': '',
...      'columnWidths': {'bdate': 13,
...                       'educ': 8,
...                       'gender': 1,
...                       'id': 8,
...                       'jobcat': 8,
...                       'jobtime': 8,
...                       'minority': 8,
...                       'prevexp': 8,
...                       'salary': 8,
...                       'salbegin': 8},
...      'fileAttributes': {},
...      'fileLabel': '05.00.00',
...      'formats': {'bdate': 'ADATE10',
...                  'educ': 'F2',
...                  'gender': 'A1',
...                  'id': 'F4',
...                  'jobcat': 'F1',
...                  'jobtime': 'F2',
...                  'minority': 'F1',
...                  'prevexp': 'F6',
...                  'salary': 'DOLLAR8',
...                  'salbegin': 'DOLLAR8'},
...      'measureLevels': {'bdate': 'ratio',
...                        'educ': 'ordinal',
...                        'gender': 'nominal',
...                        'id': 'ratio',
...                        'jobcat': 'ordinal',
...                        'jobtime': 'ratio',
...                        'minority': 'ordinal',
...                        'prevexp': 'ratio',
...                        'salary': 'ratio',
...                        'salbegin': 'ratio'},
...      'missingValues': {'bdate': {},
...                        'educ': {'values': [0.0]},
...                        'gender': {},
...                        'id': {},
...                        'jobcat': {'values': [0.0]},
...                        'jobtime': {'values': [0.0]},
...                        'minority': {'values': [9.0]},
...                        'prevexp': {},
...                        'salary': {'values': [0.0]},
...                        'salbegin': {'values': [0.0]}},
...      'multRespDefs': {},
...      'valueLabels': {'educ': {0.0: '0 (Missing)',
...                               8.0: '8',
...                               12.0: '12',
...                               14.0: '14',
...                               15.0: '15',
...                               16.0: '16',
...                               17.0: '17',
...                               18.0: '18',
...                               19.0: '19',
...                               20.0: '20',
...                               21.0: '21'},
...                      'gender': {'f': 'Female', 'm': 'Male'},
...                      'jobcat': {0.0: '0 (Missing)',
...                                 1.0: 'Clerical',
...                                 2.0: 'Custodial',
...                                 3.0: 'Manager'},
...                      'jobtime': {0.0: 'missing'},
...                      'minority': {0.0: 'No', 1.0: 'Yes', 9.0: '9 (Missing)'},
...                      'prevexp': {0.0: 'missing'},
...                      'salary': {0.0: 'missing'},
...                      'salbegin': {0.0: 'missing'}},
...      'varAttributes': {},
...      'varLabels': {'bdate': 'Date of Birth',
...                    'educ': 'Educational Level (years)',
...                    'gender': 'Gender',
...                    'id': 'Employee Code',
...                    'jobcat': 'Employment Category',
...                    'jobtime': 'Months since Hire',
...                    'minority': 'Minority Classification',
...                    'prevexp': 'Previous Experience (months)',
...                    'salary': 'Current Salary',
...                    'salbegin': 'Beginning Salary'},
...      'varNames': ['id',
...                   'gender',
...                   'bdate',
...                   'educ',
...                   'jobcat',
...                   'salary',
...                   'salbegin',
...                   'jobtime',
...                   'prevexp',
...                   'minority'],
...      'varRoles': {'bdate': 'input',
...                   'educ': 'input',
...                   'gender': 'input',
...                   'id': 'input',
...                   'jobcat': 'input',
...                   'jobtime': 'input',
...                   'minority': 'input',
...                   'prevexp': 'input',
...                   'salary': 'input',
...                   'salbegin': 'input'},
...      'varSets': {'DEMOGR': ['gender', 'minority', 'educ'],
...                  'SALARY': ['salbegin', 'salary']},
...      'varTypes': {'bdate': 0,
...                   'educ': 0,
...                   'gender': 1,
...                   'id': 0,
...                   'jobcat': 0,
...                   'jobtime': 0,
...                   'minority': 0,
...                   'prevexp': 0,
...                   'salary': 0,
...                   'salbegin': 0}}
>>> desired == wholeDict
True