{ "info": { "author": "dirkmjk", "author_email": "info@dirkmjk.nl", "bugtrack_url": null, "classifiers": [], "description": "[LimeSurvey][limesurvey] is open-source survey software. Using pandas, the limepy package simplifies a number of tasks when working with LimeSurvey data:\n\n- Downloading survey data. This requires that LimeSurvey\u2019s RemoteControl 2 API is enabled, as explained [here][LSRC2].\n- Creating a list of al the questions in the survey, with metadata.\n- Summarising data, e.g. creating value counts for multi-column items such as multiple-choice questions; calculating averages for number arrays; or creating scores for a ranking question.\n- Printing answers to open-ended questions.\n- Printing the answers of an individual respondent.\n\nNote that limepy uses f-strings and therefore requires Python 3.6 or higher.\n\nUse at your own risk and please make sure to check the results.\n\n# How is it different\n\nThere are various python packages for managing the LimeSurvey RemoteControl 2 API. While limepy can help you download survey data, the emphasis is on processing and summarising the data.\n\n# Examples\n\n## Download survey data\n\nYou can download survey data with the RemoteControl 2 API (provided the api is enabled in your LimeSurvey installation).\n\nFor a one-off download, you can of course do this manually. However, you may want to use the api if you want to write a preliminary report based on the first responses, and then automatically update it as new responses come in.\n\n```python\nfrom pathlib import Path\nfrom limepy import download\n\ncsv = download.get_responses(base_url, user_name, password, user_id, sid)\npath = Path('../data/data.csv')\npath.write_text(csv)\n```\n\n## Create Survey object\n\nA Survey object contains the data and metadata of a survey. To create a Survey object, you need:\n\n- A csv containing the survey results. You can download it manually or use the api as described above. Make sure to set heading type to 'code' and reponse type to 'short'.\n- An .lss file containing the survey structure. You can download this manually.\n\n```python\nfrom limepy.wrangle import Survey, Question\nimport pandas as pd\n\ndf = pd.read_csv('../data/data.csv', sep=';')\nmy_structure = open('../data/structure.lss').read()\n\nmy_survey = Survey(df, my_structure)\n```\n\nNote: if you use a merged dataframe (for example, data from various versions of the same questionnaire), you should reset the index before creating a Survey object.\n\n## Get list of questions with metadata\n\n```python\nmy_survey.question_list\n```\n\n## Print results for individual respondent\n\nThe `respondent` method will return a string listing the answers of an individual respondent. You need the respondent\u2019s row index.\n\n```python\nmy_survey.respondent(26)\n```\n\n## Create a readable dataframe\n\nCreate a dataframe with full questions as column names and \u2018long\u2019 responses as values.\n\n```python\nmy_survey.readable_df\n```\n\n## Create a Question object\n\nA Question object can be used to summarise data. To create a Question oject, you need a Survey object and the question id (find it in the index of the question list).\n\n```python\nmy_question = Question(my_survey, 3154)\n```\n\nIf you want to use a subset of the respondents for your analysis (e.g., exclude respondents that do not meet certain criteria, or drop duplicates), the most practical approach is probably to create a subset first and use that to create your Survey object. However, you can also use a mask if you want to create a Question object for a subset of the respondents.\n\n```python\nmy_question = Question(my_survey, 3154, mask=pd.notnull(df.iloc[:, 8]))\n```\n\n## Summarise answers to a question\n\nFor many question types, limepy can summarise the results. \n- In many cases, this will return a dataframe containing value counts (as well as Percent and Valid Percent). \n- In case of a Numerical input question, the output will be a dataframe containing the results of the pandas DataFrame `describe` method. \n- In case of a Numbers array question, the average will be calculated for each option (but you must specify the method, i.e. 'mean' or 'median'). \n- In case of a Ranking question, the result will be a dataframe with scores calculated for each item. \n- If no method has been implemented for a question type, a dataframe will be returned which contains the columns associated with the question.\n\n```python\nmy_question.summary\n```\n\nTo show the metadata associated with a question:\n\n```python\nmy_question.metadata\n```\n\n## Write answers to an open-ended question\n\nThe `write_open_ended` method creates a string listing all the answers to the question. Optionally, you can specify a list of indices of columns that contain background information you want included in the output.\n\n```python\nmy_question.write_open_ended(background_column_indices=[9])\n```\n\nYou can also create a folder and store text files containing the answers to all open-ended questions in the survey.\n\n```python\nfrom pathlib import Path\n\nremove = ' _?:/()'\n\ndef include(row):\n for string in ['free text', 'comment']:\n if string in row.question_type:\n return True\n if row.other == 'Y':\n return True\n return False\n\nfor qid, row in my_survey.question_list.iterrows():\n if include(row):\n question = row.question\n for char in remove:\n question = question.replace(char, ' ')\n question = question[:25]\n path = Path('../data/open_ended') / f'{qid} {question}.md'\n path.write_text(Question(sv, qid).write_open_ended(background_column_indices=[9]))\n```\n\n## Create report as html\n\n```python\ndef add_table(question, question_text=None):\n \"\"\"Add table summarising question\"\"\"\n\n if not question_text:\n question_text = question.question\n html = f\"
{question_text}
\\n\"\n html += question.summary.to_html() + '\\n'\n help_txt = question.metadata['help']\n if help_txt:\n html += f\"
{help_txt}
\"\n return html\n\n\nhtml = \"\"\"\nTitle\n\n\n\n\n\"\"\"\n\nmy_question = Question(my_survey, 44)\nhtml += add_table(my_question)\n\nhtml += \"\"\n```\n\n[limesurvey]:https://en.wikipedia.org/wiki/LimeSurvey\n[LSRC2]:https://manual.limesurvey.org/RemoteControl_2_API\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/DIRKMJK/limepy", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "limepy", "package_url": "https://pypi.org/project/limepy/", "platform": "", "project_url": "https://pypi.org/project/limepy/", "project_urls": { "Homepage": "https://github.com/DIRKMJK/limepy" }, "release_url": "https://pypi.org/project/limepy/0.1.3/", "requires_dist": [ "pandas", "numpy", "requests", "xmltodict" ], "requires_python": "", "summary": "Download, summarise and process LimeSurvey data", "version": "0.1.3" }, "last_serial": 5151064, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "69d551700925c0682c419261aec84cef", "sha256": "1c2565fcbc7e7ad054fa9db57d493f6bb56b7d855074d37de4f478e624840750" }, "downloads": -1, "filename": "limepy-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "69d551700925c0682c419261aec84cef", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 8906, "upload_time": "2019-01-08T19:19:33", "url": "https://files.pythonhosted.org/packages/2f/67/a0fd13f85c2d15526a816faa7557a076dc01418195f14afbd860ad420b54/limepy-0.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "fbf5331ae836fcf25b065d40ebf4ca99", "sha256": "06e021b4d3225a014546ff5a4b8848d63a28b15aba02d3ad14b6465734a2d586" }, "downloads": -1, "filename": "limepy-0.1.0.tar.gz", "has_sig": false, "md5_digest": "fbf5331ae836fcf25b065d40ebf4ca99", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8486, "upload_time": "2019-01-08T19:19:35", "url": "https://files.pythonhosted.org/packages/96/a8/7f35ae444ad5ea9fdf89764bccbe1b478e2aa77c8d06dc29226253d3a836/limepy-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "12c3457bfbaf4cd803b80315a33d9cf7", "sha256": "8fb10bc58cf0c13046c534aa7b840644a62e3db38bd28eee4a96e724966a3bbf" }, "downloads": -1, "filename": "limepy-0.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "12c3457bfbaf4cd803b80315a33d9cf7", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 9000, "upload_time": "2019-02-17T07:53:18", "url": "https://files.pythonhosted.org/packages/f2/73/9584319e34e9efe3954c8375a9542f8772426b1ae07abb0e82bf99a6664b/limepy-0.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "13c1c1b50a275721c0bb6daa90e8cd4c", "sha256": "4690169a7e3da58a369c0227d74056b97728917be602099f91c6d6a17aa56f40" }, "downloads": -1, "filename": "limepy-0.1.1.tar.gz", "has_sig": false, "md5_digest": "13c1c1b50a275721c0bb6daa90e8cd4c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8563, "upload_time": "2019-02-17T07:53:20", "url": "https://files.pythonhosted.org/packages/eb/4d/ba96c7b6dc92fe8a31cea021157a2e19db1526a9f72aa3b455901a211951/limepy-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "b16d2573a5662c64dbcd72d144852122", "sha256": "ac24e585fccb30273afd6e5e2d91937a712a0bcf65981f1ead23f84a5072ebbc" }, "downloads": -1, "filename": "limepy-0.1.2-py3-none-any.whl", "has_sig": false, "md5_digest": "b16d2573a5662c64dbcd72d144852122", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 9059, "upload_time": "2019-03-15T14:03:03", "url": "https://files.pythonhosted.org/packages/7b/6d/da3cfc3d2cf5662ce8fc6af3fc3741beb21d94053217a43f3b5d99e7a861/limepy-0.1.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a8a73cfd3f8b96344388e2b7d0f4b8fd", "sha256": "95d4cbf41f04b4c72dae8d29f45f4ad3d598c08f92f2475c26b55ba55a3f38bf" }, "downloads": -1, "filename": "limepy-0.1.2.tar.gz", "has_sig": false, "md5_digest": "a8a73cfd3f8b96344388e2b7d0f4b8fd", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8614, "upload_time": "2019-03-15T14:03:05", "url": "https://files.pythonhosted.org/packages/88/87/b3ed01d8922e77cc6d336aca0be1abd774ce510ba8ddb2d477a06d32328f/limepy-0.1.2.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "d0907c653a97003712a4c46573d6f11c", "sha256": "a6800abcada2812ad19a23158b729492e27e01f3c3dfaa819ed6ae786a5e21d2" }, "downloads": -1, "filename": "limepy-0.1.3-py3-none-any.whl", "has_sig": false, "md5_digest": "d0907c653a97003712a4c46573d6f11c", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 9613, "upload_time": "2019-04-16T17:11:30", "url": "https://files.pythonhosted.org/packages/4a/be/45a78bbef395e45be81e40f7be9ff69a4b45c26cb5fd98f2abcf0caf6110/limepy-0.1.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "b10c739be4e081be1cbd9a4924477832", "sha256": "3ea4ac8913e90caaad1ff984db0c5fe5434ad516685a5b8ff1fe3b8dc6aa8bf8" }, "downloads": -1, "filename": "limepy-0.1.3.tar.gz", "has_sig": false, "md5_digest": "b10c739be4e081be1cbd9a4924477832", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9250, "upload_time": "2019-04-16T17:11:32", "url": "https://files.pythonhosted.org/packages/c9/7a/93d1c72faa6c84c192973d063ffa2b4a608792f189b33f05e077a5b28363/limepy-0.1.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "d0907c653a97003712a4c46573d6f11c", "sha256": "a6800abcada2812ad19a23158b729492e27e01f3c3dfaa819ed6ae786a5e21d2" }, "downloads": -1, "filename": "limepy-0.1.3-py3-none-any.whl", "has_sig": false, "md5_digest": "d0907c653a97003712a4c46573d6f11c", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 9613, "upload_time": "2019-04-16T17:11:30", "url": "https://files.pythonhosted.org/packages/4a/be/45a78bbef395e45be81e40f7be9ff69a4b45c26cb5fd98f2abcf0caf6110/limepy-0.1.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "b10c739be4e081be1cbd9a4924477832", "sha256": "3ea4ac8913e90caaad1ff984db0c5fe5434ad516685a5b8ff1fe3b8dc6aa8bf8" }, "downloads": -1, "filename": "limepy-0.1.3.tar.gz", "has_sig": false, "md5_digest": "b10c739be4e081be1cbd9a4924477832", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9250, "upload_time": "2019-04-16T17:11:32", "url": "https://files.pythonhosted.org/packages/c9/7a/93d1c72faa6c84c192973d063ffa2b4a608792f189b33f05e077a5b28363/limepy-0.1.3.tar.gz" } ] }