Skip to main content

a wrapper for using Task Analytics APIs and downloading survey responses

Project description

Task Analytics Data Wrapper

Code style: black

This is a wrapper for Task Analytics APIs. You can use it to download survey responses and metadata for each survey.

Supported APIs

Log in to Task Analytics

You can log in with email and password

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.

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.

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

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

get_openended_survey = task.download_discovery_survey(
    username=email, password=password, organization_id=organization, survey_id="03230"
)

See how to turn this into csv in the code example below by expanding

Expandable example
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)

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

taskanalytics_data_wrapper-0.1.9.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file taskanalytics_data_wrapper-0.1.9.tar.gz.

File metadata

File hashes

Hashes for taskanalytics_data_wrapper-0.1.9.tar.gz
Algorithm Hash digest
SHA256 dd2091cd2459eef7205786a2e26b5b4c5b265066dfa92f14d6b447d8756720fa
MD5 271b5800e5bc7bf125744d62d4152cc1
BLAKE2b-256 934a398849c10ce795ab1b66969579d7865a381042169bde1edb5dc459203729

See more details on using hashes here.

File details

Details for the file taskanalytics_data_wrapper-0.1.9-py3-none-any.whl.

File metadata

File hashes

Hashes for taskanalytics_data_wrapper-0.1.9-py3-none-any.whl
Algorithm Hash digest
SHA256 25be4b95b74a7003c3a9ea7d07fabfa61f19880bcea26ee042847310f7e4a56b
MD5 5d8adbff5803fc209b7e480e11f70da4
BLAKE2b-256 80ed30c766ec40f0f4413aa79fd6f1772433528c11f25ccfa1b81fe65ce54d80

See more details on using hashes here.

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