Skip to main content

No project description provided

Project description

Travis
Coveralls
PyPi
SemVer
Gitter

Read and write between SPSS and Table Schema.

Getting Started

Installation

pip install tableschema-spss

Storage

Package implements the Tabular Storage interface.

We can get storage this way:

from tableschema_spss import Storage

storage_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 storage
storage.create('bucket', descriptor)
storage.delete('bucket')  # deletes named bucket
storage.delete()  # deletes all buckets in storage
storage.describe('bucket') # return tableschema descriptor
storage.iter('bucket') # yields rows
storage.read('bucket') # return rows
storage.write('bucket', rows)

Reading .sav files

When reading SPSS data, SPSS date formats, DATE, JDATE, EDATE, SDATE, ADATE, DATETIME, and TIME are transformed into Python date, datetime, and time objects, where appropriate.

Other SPSS date formats, WKDAY, MONTH, MOYR, WKYR, QYR, and DTIME are not supported for native transformation and will be returned as strings.

Creating .sav files

When creating SPSS files from Table Schemas, date, datetime, and time field types must have a format property defined with the following patterns:

  • date: %Y-%m-%d

  • datetime: %Y-%m-%d %H:%M:%S

  • time: %H:%M:%S.%f

Table Schema descriptors passed to storage.create() should include a custom spss:format property, 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"
        }
    ]
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tableschema-spss-0.1.0.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

tableschema_spss-0.1.0-py2.py3-none-any.whl (9.1 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file tableschema-spss-0.1.0.tar.gz.

File metadata

File hashes

Hashes for tableschema-spss-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2404a78a976e66d2b30fb306511dbce70f28fa76a6169ff0c1298ffadc36b41f
MD5 98092b0add7a2f0e43f98aa9f7e1e7f5
BLAKE2b-256 b10409dd86ee89cda4b869a45f1b570ad7519d705e83e0dbd579dca9dcf7ec02

See more details on using hashes here.

Provenance

File details

Details for the file tableschema_spss-0.1.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for tableschema_spss-0.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 9e9d2ea02bb3c5f933d8b28111f5ec0197ba3b206921f29c2e1dbd1eb033b8c1
MD5 727f517b92cd80994b4f4ee42e0ca2ff
BLAKE2b-256 7cb9c3a81f405a3062037ebb8f188417a855a6f380d1840673ca750a494c7095

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page