Name | taskanalytics-data-wrapper JSON |
Version |
0.2.2
JSON |
| download |
home_page | None |
Summary | a wrapper for using Task Analytics APIs and downloading survey responses |
upload_time | 2024-12-05 07:12:11 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.10 |
license | MIT License Copyright (c) 2022 NAV IT Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
keywords |
task analytics
top tasks
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Task Analytics Data Wrapper
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
This is a wrapper for Task Analytics APIs. You can use it to download survey responses and metadata for each survey.
## Supported APIs
- [Task Analytics Data Wrapper](#task-analytics-data-wrapper)
- [Supported APIs](#supported-apis)
- [Log in to Task Analytics](#log-in-to-task-analytics)
- [Download Survey responses](#download-survey-responses)
- [Download Survey metadata](#download-survey-metadata)
- [Download Discovery survey responses](#download-discovery-survey-responses)
### Log in to Task Analytics
You can log in with email and password
```python
status = log_in_taskanalytics(username=email, password=password)
status.status_code
```
### Download Survey responses
You can download survey responses for a Top Task survey using the survey ID, email, password and setting a path for where to store the file.
```python
import taskanalytics_data_wrapper.taskanalytics_api as task
get_survey = task.download_survey(
username=email, password=password, survey_id="03324", filename="data/survey.csv"
)
get_survey.status_code
```
### Download Survey metadata
You can download the survey metadata which includes the questions and response options for each survey using the survey ID, email and password.
```python
survey_metadata = task.get_survey_metadata(
username=email, password=password, survey_id="03324"
)
survey_metadata.status_code
```
The object can be easily inspected transformed into a dictionary for analysis
```python
survey_metadata.text # survey metadata
our_dict = survey_metadata.json() # convert string to dict and store as a variable
```
### Download Discovery survey responses
You can download responses from open ended task discovery surveys as well
```python
get_openended_survey = task.download_discovery_survey(
username=email,
password=password,
organization_id=organization,
survey_id="03230",
filename_path="data/open_ended_survey.json",
)
```
See how to turn this into csv in the code example below by expanding
<details>
<summary>Expandable example</summary>
```python
data = get_openended_survey.json()
#create a new dict from our subset of data
def flatten_openended_dict(data):
""" """
respondent = []
completion = []
category = []
discovery = []
comment = []
for i in data:
respondent.append(i["id"])
completion.append(i["completion"])
category.append(i["category"])
discovery.append(i["answers"]["discovery"])
try:
comment.append(i["answers"]["comment"])
except:
comment.append("")
newlist = [
{
"id": respondent,
"completion": completion,
"category": category,
"discovery": discovery,
"comment": comment,
}
for respondent, completion, category, discovery, comment in zip(
respondent, completion, category, discovery, comment
)
]
return newlist
newlist = flatten_openended_dict(data["responses"])
# write open ended survey to csv with your preferred encoding and delimiter
keys = newlist[0].keys()
with open("data/open_survey.csv", "w", encoding="utf-8-sig", newline="") as output_file:
writer = csv.DictWriter(output_file, fieldnames=keys, delimiter=";")
writer.writeheader()
writer.writerows(newlist)
```
</details>
Raw data
{
"_id": null,
"home_page": null,
"name": "taskanalytics-data-wrapper",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": "Task Analytics, Top Tasks",
"author": null,
"author_email": "Tobias McVey <tobias.mcvey@nav.no>",
"download_url": "https://files.pythonhosted.org/packages/c5/78/5400901f4f42bac9edbcb5d81d01a4839725a0d296b3cc386feee617d79e/taskanalytics_data_wrapper-0.2.2.tar.gz",
"platform": null,
"description": "# Task Analytics Data Wrapper\n\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n\nThis is a wrapper for Task Analytics APIs. You can use it to download survey responses and metadata for each survey.\n\n## Supported APIs\n\n- [Task Analytics Data Wrapper](#task-analytics-data-wrapper)\n - [Supported APIs](#supported-apis)\n - [Log in to Task Analytics](#log-in-to-task-analytics)\n - [Download Survey responses](#download-survey-responses)\n - [Download Survey metadata](#download-survey-metadata)\n - [Download Discovery survey responses](#download-discovery-survey-responses)\n\n### Log in to Task Analytics\n\nYou can log in with email and password\n\n```python\nstatus = log_in_taskanalytics(username=email, password=password) \nstatus.status_code\n```\n\n### Download Survey responses\n\nYou can download survey responses for a Top Task survey using the survey ID, email, password and setting a path for where to store the file.\n\n```python\nimport taskanalytics_data_wrapper.taskanalytics_api as task\n\nget_survey = task.download_survey(\n username=email, password=password, survey_id=\"03324\", filename=\"data/survey.csv\"\n)\nget_survey.status_code\n```\n\n### Download Survey metadata\n\nYou can download the survey metadata which includes the questions and response options for each survey using the survey ID, email and password.\n\n```python\nsurvey_metadata = task.get_survey_metadata(\n username=email, password=password, survey_id=\"03324\"\n)\nsurvey_metadata.status_code\n```\n\nThe object can be easily inspected transformed into a dictionary for analysis\n\n```python\nsurvey_metadata.text # survey metadata\nour_dict = survey_metadata.json() # convert string to dict and store as a variable\n```\n\n### Download Discovery survey responses\n\nYou can download responses from open ended task discovery surveys as well\n\n```python\nget_openended_survey = task.download_discovery_survey(\n username=email,\n password=password,\n organization_id=organization,\n survey_id=\"03230\",\n filename_path=\"data/open_ended_survey.json\",\n)\n```\nSee how to turn this into csv in the code example below by expanding\n\n<details>\n<summary>Expandable example</summary>\n\n```python\ndata = get_openended_survey.json()\n\n#create a new dict from our subset of data\ndef flatten_openended_dict(data):\n \"\"\" \"\"\"\n respondent = []\n completion = []\n category = []\n discovery = []\n comment = []\n for i in data:\n respondent.append(i[\"id\"])\n completion.append(i[\"completion\"])\n category.append(i[\"category\"])\n discovery.append(i[\"answers\"][\"discovery\"])\n try:\n comment.append(i[\"answers\"][\"comment\"])\n except:\n comment.append(\"\")\n newlist = [\n {\n \"id\": respondent,\n \"completion\": completion,\n \"category\": category,\n \"discovery\": discovery,\n \"comment\": comment,\n }\n for respondent, completion, category, discovery, comment in zip(\n respondent, completion, category, discovery, comment\n )\n ]\n return newlist\n\n\nnewlist = flatten_openended_dict(data[\"responses\"])\n\n# write open ended survey to csv with your preferred encoding and delimiter\nkeys = newlist[0].keys()\n\nwith open(\"data/open_survey.csv\", \"w\", encoding=\"utf-8-sig\", newline=\"\") as output_file:\n writer = csv.DictWriter(output_file, fieldnames=keys, delimiter=\";\")\n writer.writeheader()\n writer.writerows(newlist)\n```\n</details>\n",
"bugtrack_url": null,
"license": "MIT License Copyright (c) 2022 NAV IT Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
"summary": "a wrapper for using Task Analytics APIs and downloading survey responses",
"version": "0.2.2",
"project_urls": {
"Homepage": "https://github.com/navikt/taskanalytics-data-wrapper"
},
"split_keywords": [
"task analytics",
" top tasks"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "7de9df2dc63e4fe4817c0c3e7fc8ec3416ba8e60bddd7d68c5768efc098d979d",
"md5": "e2e03971c8ede1413e5ede80d8ce5ed3",
"sha256": "fdaebd38050e9888db3e41835737dfae322a3982d1e71248961f28f508bc6707"
},
"downloads": -1,
"filename": "taskanalytics_data_wrapper-0.2.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "e2e03971c8ede1413e5ede80d8ce5ed3",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 5635,
"upload_time": "2024-12-05T07:12:10",
"upload_time_iso_8601": "2024-12-05T07:12:10.201369Z",
"url": "https://files.pythonhosted.org/packages/7d/e9/df2dc63e4fe4817c0c3e7fc8ec3416ba8e60bddd7d68c5768efc098d979d/taskanalytics_data_wrapper-0.2.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "c5785400901f4f42bac9edbcb5d81d01a4839725a0d296b3cc386feee617d79e",
"md5": "cd44d0c7c8eb9d898a2e17056074dcbb",
"sha256": "4981f831fb6731f87d1f1a0d4cbd4170cb4a7ec550dc047aeccb327dd66a9a12"
},
"downloads": -1,
"filename": "taskanalytics_data_wrapper-0.2.2.tar.gz",
"has_sig": false,
"md5_digest": "cd44d0c7c8eb9d898a2e17056074dcbb",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 8755,
"upload_time": "2024-12-05T07:12:11",
"upload_time_iso_8601": "2024-12-05T07:12:11.857500Z",
"url": "https://files.pythonhosted.org/packages/c5/78/5400901f4f42bac9edbcb5d81d01a4839725a0d296b3cc386feee617d79e/taskanalytics_data_wrapper-0.2.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-05 07:12:11",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "navikt",
"github_project": "taskanalytics-data-wrapper",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "taskanalytics-data-wrapper"
}