-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: Document usage in R with
reticulate
(#1227)
* docs: Document usage in R with `reticulate` * Update docs/how-to.md * Revert "Update docs/how-to.md" This reverts commit e0e7351.
- Loading branch information
1 parent
6c5f755
commit 9c5a68f
Showing
5 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
kind: Documentation | ||
body: survey_data | ||
time: 2024-11-29T21:48:18.300822-06:00 | ||
custom: | ||
Issue: "1227" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# start example | ||
> library(reticulate) | ||
> reticulate::use_virtualenv("venv") | ||
> reticulate::source_python("export_ls_responses.py") | ||
> py$survey_data | ||
submitdate lastpage startlanguage seed G01Q01 G01Q02 G02Q03 G02Q03[filecount] | ||
1 [nan] [1] ['en'] [245240561] ['lalala'] [5] [nan] [nan] | ||
# end example |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
"""Use reticulate to export LimeSurvey data to R.""" | ||
|
||
# ruff: noqa: T201 | ||
|
||
from __future__ import annotations | ||
|
||
# start example | ||
# export_ls_responses.py | ||
import io | ||
|
||
import citric | ||
import pandas as pd | ||
|
||
client = citric.Client( | ||
"http://localhost:8001/index.php/admin/remotecontrol", | ||
"iamadmin", | ||
"secret", | ||
) | ||
data = client.export_responses(123456, file_format="csv") | ||
survey_data = pd.read_csv( | ||
io.BytesIO(data), | ||
delimiter=";", | ||
parse_dates=["datestamp", "startdate", "submitdate"], | ||
index_col="id", | ||
) | ||
# end example |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters