No project description provided
Project description
Read and write between SPSS and Table Schema.
Getting Started
Installation
pip install tableschema-spss
Storage
Package implements the Tabular Storage interface.
With a base path
We can get storage with a specified base path 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)
Without a base path
We can also create storage without a base path this way:
from tableschema_spss import Storage
storage = Storage() # no base path argument
Then 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 file
storage.describe('data/my-bucket.sav') # return tableschema descriptor
storage.iter('data/my-bucket.sav') # yields rows
storage.read('data/my-bucket.sav') # return rows
storage.write('data/my-bucket.sav', rows)
Note that storage without base paths does not maintain an internal list of buckets, so calling storage.buckets will return None.
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file tableschema-spss-0.2.0.tar.gz
.
File metadata
- Download URL: tableschema-spss-0.2.0.tar.gz
- Upload date:
- Size: 8.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b87021aa85e83e1e7b5e771649bbeb253cb6d8ddf73634cf9714634fc77a71a0 |
|
MD5 | 118c585ad42129f089531f9eb740caba |
|
BLAKE2b-256 | d99b9f6890f2992b2c6ef839c96ee5b7fdde362f64f4dda33660db30a0b4adcf |
Provenance
File details
Details for the file tableschema_spss-0.2.0-py2.py3-none-any.whl
.
File metadata
- Download URL: tableschema_spss-0.2.0-py2.py3-none-any.whl
- Upload date:
- Size: 9.7 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0b0a8a8b14b8b3e206c63d3fdf942ff2b5ffe60c1bdfd295a76c947b25e88dd2 |
|
MD5 | 8d4bb9350f0e33424a2de421ded3275e |
|
BLAKE2b-256 | 1f7277bc4b919a3ed9a2bdc800080fdbe1e0836b6dbc6605b8bd825f1d3b22bf |