Package: tableschema-spss
tableschema-spss-pyGenerate and load SPSS files based onTable Schemadescriptors.Featuresimplementstableschema.StorageinterfaceContentsGetting StartedInstallationExamplesDocumentationStorageContributingChangelogGetting StartedInstallationThe package use semantic versioning. It means that major versions  could include breaking changes. It's highly recommended to specifypackageversion range in yoursetup/requirementsfile e.g.package>=1.0,<2.0.pipinstalltableschema-spssExamplesCode examples in this readme requires Python 3.3+ interpreter. You could see even more example inexamplesdirectory.For this example your schema should be compatible with SPSS storage -https://github.com/frictionlessdata/tableschema-spss-py#creating-sav-filesfromtableschemaimportTable# Load and save table to SPSStable=Table('data.csv',schema='schema.json')table.save('data',storage='spss',base_path='dir/path')DocumentationThe whole public API of this package is described here and follows semantic versioning rules. Everyting outside of this readme are private API and could be changed without any notification on any new version.StoragePackage implementsTabular Storageinterface (see full documentation on the link):This driver provides an additional API:Storage(base_path=None)base_path (str)- a valid directory path where .sav files can be created and read. If no base_path is provided, the Storage object methods will accept file paths rather than bucket names.storage.bucketsList all .sav and .zsav files at base path. Bucket list is only maintained if Storage has a valid base path, otherwise will return None.(str[]/None)- returns bucket list or NoneWith a base pathWe can get storage with a specified base path this way:fromtableschema_spssimportStoragestorage_base_path='path/to/storage/dir'storage=Storage(storage_base_path)We can then interact with storage buckets ('buckets' are SPSS .sav/.zsav files in this context):storage.buckets# list buckets in storagestorage.create('bucket',descriptor)storage.delete('bucket')# deletes named bucketstorage.delete()# deletes all buckets in storagestorage.describe('bucket')# return tableschema descriptorstorage.iter('bucket')# yields rowsstorage.read('bucket')# return rowsstorage.write('bucket',rows)Without a base pathWe can also create storage without a base path this way:fromtableschema_spssimportStoragestorage=Storage()# no base path argumentThen we can specify SPSS files directly by passing their file path (instead of bucket names):storage.create('data/my-bucket.sav',descriptor)storage.delete('data/my-bucket.sav')# deletes named filestorage.describe('data/my-bucket.sav')# return tableschema descriptorstorage.iter('data/my-bucket.sav')# yields rowsstorage.read('data/my-bucket.sav')# return rowsstorage.write('data/my-bucket.sav',rows)Note that storage without base paths does not maintain an internal list of buckets, so callingstorage.bucketswill returnNone.Reading .sav filesWhen reading SPSS data, SPSS date formats,DATE,JDATE,EDATE,SDATE,ADATE,DATETIME, andTIMEare transformed into Pythondate,datetime, andtimeobjects, where appropriate.Other SPSS date formats,WKDAY,MONTH,MOYR,WKYR,QYR, andDTIMEare not supported for native transformation and will be returned as strings.Creating .sav filesWhen creating SPSS files from Table Schemas,date,datetime, andtimefield types must have a format property defined with the following patterns:date:%Y-%m-%ddatetime:%Y-%m-%d %H:%M:%Stime:%H:%M:%S.%fTable Schema descriptors passed tostorage.create()should include a customspss:formatproperty, defining the SPSS type format the data is expected to represent. E.g.:{"fields":[{"name":"person_id","type":"integer","spss:format":"F8"},{"name":"name","type":"string","spss:format":"A10"},{"type":"number","name":"salary","title":"Current Salary","spss:format":"DOLLAR8"},{"type":"date","name":"bdate","title":"Date of Birth","format":"%Y-%m-%d","spss:format":"ADATE10"}]}ContributingThe project follows theOpen Knowledge International coding standards.Recommended way to get started is to create and activate a project virtual environment.
To install package and development dependencies into active environment:$ make installTo run tests with linting and coverage:$maketestFor lintingpylamaconfigured inpylama.iniis used. On this stage it's already
installed into your environment and could be used separately with more fine-grained control
as described in documentation -https://pylama.readthedocs.io/en/latest/.For example to sort results by error type:$pylama--sort<path>For testingtoxconfigured intox.iniis used.
It's already installed into your environment and could be used separately with more fine-grained control as described in documentation -https://testrun.org/tox/latest/.For example to check subset of tests against Python 2 environment with increased verbosity.
All positional arguments and options after--will be passed topy.test:tox-epy27---vtests/<path>Under the hoodtoxusespytestconfigured inpytest.ini,coverageandmockpackages. This packages are available only in tox envionments.ChangelogHere described only breaking and the most important changes. The full changelog and documentation for all released versions could be found in nicely formattedcommit history.v1.0Initial driver release