An open source python package to connect survey data to the survey definition defined by tsapi
Project description
tsapiness
tsapiness (pronounced "zappiness") aims to make the TSAPI easy to access via Python.
Currently, the project provides a python representation of the TSAPI so that the data can be manipulated accordingly. More details on TSAPI can be found here. https://www.tsapi.net/
These are early days for the project, in this early version you can:
- convert an SPSS sav file to tsapi format
- convert a triple-s file to tsapi format
- read tsapi from a webserver
Future development intends to:
- convert other survey platform APIs to the tsapi format
- provide tools for converting flat tsapi structures that occur when importing from sav or triple-s into the more native hierarchical tsapi structure
- provide full documentation on how to use tsapiness effectively.
A simple implementation is below...
import tsapiness as ts
import json
# Create tsapi object from TSAPI demo server
SERVER = 'https://tsapi-demo.azurewebsites.net'
conn = ts.connector_tsapi.Connection(server=SERVER)
surveys = ts.connector_tsapi.Surveys(connection=conn)
survey_id = surveys[0]['id']
survey_from_api = ts.connector_tsapi.Survey(survey_id=survey_id, connection=conn)
# create tsapi from triple s file:
sss_file = 'data/example.sss'
asc_file = 'data/example.asc'
conn = ts.connector_sss.Connection(sss_file=sss_file, asc_file=asc_file)
survey_from_sss = ts.connector_sss.Survey(connection=conn)
# create tsapi from sav file:
sav_file = 'data/Pew Global Attitudes Spring 2014.sav'
conn = ts.connector_sav.Connection(sav_file=sav_file)
# in this file the variable PSRAID holds the respid,
# and Q165 the date of interview
survey_from_sav = ts.connector_sav.Survey(connection=conn,
id_var='PSRAID',
date_var='Q165')
# save back to json
survey_to_export = survey_from_sav
# survey_to_export = survey_from_sss
# survey_to_export = survey_from_api
with open('data/metadata.json', 'w', encoding='utf8') as f:
json.dump(survey_to_export.metadata.to_tsapi(),
f,
indent=4,
ensure_ascii=False)
with open('data/data.json', 'w', encoding='utf8') as f:
json.dump([interview.to_tsapi()
for interview in survey_to_export.interviews],
f,
indent=4,
ensure_ascii=False)
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tsapiness-0.0.4.tar.gz.
File metadata
- Download URL: tsapiness-0.0.4.tar.gz
- Upload date:
- Size: 11.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a7ecde89542d2a22c8082a6db8c21b08790b1d6309ca4f78a11c8a3f3de96325
|
|
| MD5 |
a646d46c56c3a22ef0b7cd53eabcc331
|
|
| BLAKE2b-256 |
2df398d9590eddbc152f787c4f55528b4c4561fb95982654b8587e96b8c64288
|
File details
Details for the file tsapiness-0.0.4-py3-none-any.whl.
File metadata
- Download URL: tsapiness-0.0.4-py3-none-any.whl
- Upload date:
- Size: 11.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6916c39aa6104026a6a29ab1ff9405a2166a26f711458ec63ec3cf78ca4c04cb
|
|
| MD5 |
2fa3dafc3503d9261d4f32b9edbb9d5b
|
|
| BLAKE2b-256 |
59a2e002b58cfc1f94b354cf987b83953e343d057067424ba0580281a21401e0
|