Source

savReaderWriter / savReaderWriter / doc_tests / test_SavReader_file_info.txt

Full commit
##############################################################################
## Read a file and get some basic file info
##############################################################################

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

## ... Get some basic file info
>>> savFileName = "../savReaderWriter/test_data/Employee data.sav"
>>> try:  # doctest: +ELLIPSIS
...     reader = SavReader(savFileName)      
...     numVars, nCases, varNames, varTypes, formats, \
...          varLabels, valueLabels = reader.getSavFileInfo()
...     info = reader.getSavFileInfo()
... finally:
...     reader.close()
...
>>> desired = \
... (10,
...  474,
...  ['id',
...   'gender',
...   'bdate',
...   'educ',
...   'jobcat',
...   'salary',
...   'salbegin',
...   'jobtime',
...   'prevexp',
...   'minority'],
...  {'bdate': 0,
...   'educ': 0,
...   'gender': 1,
...   'id': 0,
...   'jobcat': 0,
...   'jobtime': 0,
...   'minority': 0,
...   'prevexp': 0,
...   'salary': 0,
...   'salbegin': 0},
...  {'bdate': 'ADATE10',
...   'educ': 'F2',
...   'gender': 'A1',
...   'id': 'F4',
...   'jobcat': 'F1',
...   'jobtime': 'F2',
...   'minority': 'F1',
...   'prevexp': 'F6',
...   'salary': 'DOLLAR8',
...   'salbegin': 'DOLLAR8'},
...  {'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'},
...  {'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'}})
>>> desired == info
True