Title: | Download Data from Kobotoolbox to R |
---|---|
Description: | Wrapper for 'Kobotoolbox' APIs ver 2 mentioned at <https://support.kobotoolbox.org/api.html>, to download data from 'Kobotoolbox' to R. Small and simple package that adds immense convenience for the data professionals using 'Kobotoolbox'. |
Authors: | Asitav Sen [aut, cre, cph] |
Maintainer: | Asitav Sen <[email protected]> |
License: | GPL (>= 3) |
Version: | 2.0.0 |
Built: | 2025-02-27 05:02:22 UTC |
Source: | https://github.com/asitav-sen/koboconnectr |
'get_kobo_token' is a wrapper for kobotoolbox API 'https://"[url]"/token/?format=json'
get_kobo_token( url = "eu.kobotoolbox.org", uname = "", pwd = "", encoding = "UTF-8" )
get_kobo_token( url = "eu.kobotoolbox.org", uname = "", pwd = "", encoding = "UTF-8" )
url |
The '[url]' of kobotoolbox. Default is "eu.kobotoolbox.org". |
uname |
is username of your kobotoolbox account |
pwd |
is the password of the account |
encoding |
is the encoding to be used. Default is "UTF-8". |
The function returns the API token.
The function returns the token associated with your id and password in the given url.
'kobo_df_download' is a wrapper for kobotoolbox API
kobo_df_download( url = "eu.kobotoolbox.org", uname = "", pwd = "", assetid = "", all = "false", lang = "_default", hierarchy = "false", include_grp = "true", grp_sep = "/", fsep = ";", multi_sel = "both", media_url = "true", fields = NULL, sub_ids = NULL, sleep = 2 )
kobo_df_download( url = "eu.kobotoolbox.org", uname = "", pwd = "", assetid = "", all = "false", lang = "_default", hierarchy = "false", include_grp = "true", grp_sep = "/", fsep = ";", multi_sel = "both", media_url = "true", fields = NULL, sub_ids = NULL, sleep = 2 )
url |
The '[url]' of kobotoolbox Default is "eu.kobotoolbox.org". |
uname |
is username of your kobotoolbox account |
pwd |
is the password of the account |
assetid |
is the id of the asset for which the export is to be created |
all |
takes logical value in string format. Used to specify whether fields from all form versions will be included in the export.Acceptable values are "true" or "false". Default value is "false". |
lang |
takes the language. For e.g. "English (en)". For "XML Values as headers", use '_xml'. |
hierarchy |
takes logical value in string format. Used to specify whether the group hierarchy will be displayed in labels. Acceptable values are "true" or "false". Default value is "false". |
include_grp |
defines whether or not to include groups. Default value is "true". |
grp_sep |
is the group separator. Default value is "/". |
fsep |
is the separator of the downloaded csv file. In most of the cases, it is ";", which is the default. However, if you notice that the separator is the downloaded data is "," or something else, you can change it. |
multi_sel |
is used to specify the display of multiple_select-type responses. Valid inputs include "both", "summary" or "details". Default is "both". |
media_url |
This will include an additional column for media-type questions ("question_name_URL") with the URL link to the hosted file. Valid inputs are "true" or "false". Default value is true. |
fields |
is an array of column names to be included in the export (including their group hierarchy). Valid inputs include: An array containing any string value that matches the XML column name, An empty array which will result in all columns being included, If "fields" is not included in the "export_settings", all columns will be included in the export |
sub_ids |
is an array of submission ids that will filter exported submissions to only the specified array of ids. Valid inputs include an array containing integer values or an empty array. |
sleep |
is the sleep time between API actions. For example, it takes time to download an export. But R does not wait for the download to finish before going to next step. Hence the need to provide a break between consecutive API actions. Default value is 2 (seconds). |
The function creates an export of survey data in 'csv'. If successful, it attempts to download the data and and return a data frame. Finally, the function attempts to delete the export.
The function returns a data frame of data downloaded from 'Kobotoolbox'.
'kobo_export_create' is a wrapper for kobotoolbox API 'https://[kpi-URL]/api/v2/assets/[asset-uid]/exports/'
kobo_export_create( url = "eu.kobotoolbox.org", uname = "", pwd = "", assetid = "", type = "csv", all = "false", lang = "_default", hierarchy = "false", include_grp = "true", grp_sep = "/", multi_sel = "both", fields = NULL, media_url = "true", sub_ids = NULL, qry = NULL, flatten = "true", sleep = 3 )
kobo_export_create( url = "eu.kobotoolbox.org", uname = "", pwd = "", assetid = "", type = "csv", all = "false", lang = "_default", hierarchy = "false", include_grp = "true", grp_sep = "/", multi_sel = "both", fields = NULL, media_url = "true", sub_ids = NULL, qry = NULL, flatten = "true", sleep = 3 )
url |
The '[url]' of kobotoolbox Default is "eu.kobotoolbox.org". |
uname |
is username of your kobotoolbox account |
pwd |
is the password of the account |
assetid |
is the id of the asset for which the export is to be created |
type |
specifies the export format. Valid formats include "csv","xls", "spss_labels" and "geojson" |
all |
takes logical value in string format. Used to specify whether fields from all form versions will be included in the export.Acceptable values are "true" or "false". Default value is "false". |
lang |
takes the language. For e.g. "English (en)". For "XML Values as headers", use '_xml'. |
hierarchy |
takes logical value in string format. Used to specify whether the group hierarchy will be displayed in labels. Acceptable values are "true" or "false". Default value is "false". |
include_grp |
defines whether or not to include groups. Default value is "true". |
grp_sep |
is the group separator. Default value is "/". |
multi_sel |
is used to specify the display of multiple_select-type responses. Valid inputs include "both", "summary" or "details". Default is "both". |
fields |
is an array of column names to be included in the export (including their group hierarchy). Valid inputs include: An array containing any string value that matches the XML column name, An empty array which will result in all columns being included, If "fields" is not included in the "export_settings", all columns will be included in the export |
media_url |
This will include an additional column for media-type questions ("question_name_URL") with the URL link to the hosted file. Valid inputs are "true" or "false". Default value is true. |
sub_ids |
is an array of submission ids that will filter exported submissions to only the specified array of ids. Valid inputs include an array containing integer values or an empty array.#' |
qry |
is a JSON object containing a Mongo filter query for filtering exported submissions. Valid inputs include a JSON object containing a valid Mongo query or An empty JSON object (no filtering) |
flatten |
is a is a boolean (in form of string) value and only relevant when exporting to "geojson" format. Valid inputs are "true" and "false" |
sleep |
is the sleep time between API actions. For example, it takes time to download an export. But R does not wait for the download to finish before going to next step. Hence the need to provide a break between consecutive API actions. Default value is 2 (seconds). |
The function creates an export of survey data. If successful, returns the URL of the data that can be directly downloaded/read/imported in R.
The function creates an export, prints and returns the URL of the export created
'kobo_exports' is a wrapper for kobotoolbox API 'https://[kpi-url]/api/v2/assets/[assetid]/exports/'
kobo_exports( url = "eu.kobotoolbox.org", uname = "", pwd = "", encoding = "UTF-8", assetid = "", simplified = FALSE )
kobo_exports( url = "eu.kobotoolbox.org", uname = "", pwd = "", encoding = "UTF-8", assetid = "", simplified = FALSE )
url |
The '[url]' of kobotoolbox. Default is "eu.kobotoolbox.org". |
uname |
is username of your kobotoolbox account |
pwd |
is the password of the account |
encoding |
is the encoding to be used. Default is "UTF-8" |
assetid |
the asset id |
simplified |
if TRUE, then return a simple data frame with selected data, if FALSE returns the full list. |
The function returns the export views.
The function returns a list of exports available for the account id and password entered.
'kobo_media_downloader' downloads media from data downloaded using 'kobo_df_download'. Loops through media columns and downloads files individually.
kobo_media_downloader( url = "eu.kobotoolbox.org", uname, pwd, assetid, fsep = ";", sleep = 2, identifier = "URL", timeoutval = 300, destfolder = "media" )
kobo_media_downloader( url = "eu.kobotoolbox.org", uname, pwd, assetid, fsep = ";", sleep = 2, identifier = "URL", timeoutval = 300, destfolder = "media" )
url |
The '[url]' of kobotoolbox Default is "eu.kobotoolbox.org". |
uname |
is username of your kobotoolbox account |
pwd |
is the password of the account |
assetid |
is the id of the asset for which the export is to be created |
fsep |
is the separator of the downloaded csv file. In most of the cases, it is ";", which is the default. However, |
sleep |
is the sleep time between API actions. For example, it takes time to download an export. But R does not wait for the download to finish before going to next step. Hence the need to provide a break between consecutive API actions. Default value is 2 (seconds). |
identifier |
is the key using with the columns with URL is identified. Default value is "URL" because in most of the cases, the columns containing the URL values end with "URL". Please note that any other column name with similar value may cause error. |
timeoutval |
is the timeout value in seconds to download the media files. Default is 300 seconds. |
destfolder |
is the folder where the media is to be stored. |
The function creates an export of survey data in 'csv'. If successful, it attempts to download the data and and returns a data frame. From that data frame, the function extracts the URLs of media and attempts to download them.
The function returns a data frame of data downloaded from 'Kobotoolbox'.
'kobo_xls_dl' is a wrapper for kobotoolbox API that attemps to download data in excel compatible formal.
kobo_xls_dl( url = "eu.kobotoolbox.org", uname = "", pwd = "", assetid = "", all = "false", lang = "_default", hierarchy = "false", include_grp = "true", grp_sep = "/", multi_sel = "both", media_url = "true", fields = NULL, sub_ids = NULL, sleep = 2 )
kobo_xls_dl( url = "eu.kobotoolbox.org", uname = "", pwd = "", assetid = "", all = "false", lang = "_default", hierarchy = "false", include_grp = "true", grp_sep = "/", multi_sel = "both", media_url = "true", fields = NULL, sub_ids = NULL, sleep = 2 )
url |
The '[url]' of kobotoolbox Default is "eu.kobotoolbox.org". |
uname |
is username of your kobotoolbox account |
pwd |
is the password of the account |
assetid |
is the id of the asset for which the export is to be created |
all |
takes logical value in string format. Used to specify whether fields from all form versions will be included in the export.Acceptable values are "true" or "false". Default value is "false". |
lang |
takes the language. For e.g. "English (en)". For "XML Values as headers", use '_xml'. |
hierarchy |
takes logical value in string format. Used to specify whether the group hierarchy will be displayed in labels. Acceptable values are "true" or "false". Default value is "false". |
include_grp |
defines whether or not to include groups. Default value is "true". |
grp_sep |
is the group separator. Default value is "/". |
multi_sel |
is used to specify the display of multiple_select-type responses. Valid inputs include "both", "summary" or "details". Default is "both". |
media_url |
This will include an additional column for media-type questions ("question_name_URL") with the URL link to the hosted file. Valid inputs are "true" or "false". Default value is true. |
fields |
is an array of column names to be included in the export (including their group hierarchy). Valid inputs include: An array containing any string value that matches the XML column name, An empty array which will result in all columns being included, If "fields" is not included in the "export_settings", all columns will be included in the export |
sub_ids |
is an array of submission ids that will filter exported submissions to only the specified array of ids. Valid inputs include an array containing integer values or an empty array. |
sleep |
is the sleep time between API actions. For example, it takes time to download an export. But R does not wait for the download to finish before going to next step. Hence the need to provide a break between consecutive API actions. Default value is 2 (seconds). |
The function creates an export of survey data in 'xls'. If successful, it attempts to download the data and and return a data frame (reading using 'readxl::read_excel').
The function returns a data frame of data downloaded from 'Kobotoolbox'.
'kobotools_api' is a wrapper for kobotoolbox API 'https://[kpi-url]/api/v2/assets/'
kobotools_api( url = "eu.kobotoolbox.org", simplified = TRUE, uname = "", pwd = "", encoding = "UTF-8", qry = "" )
kobotools_api( url = "eu.kobotoolbox.org", simplified = TRUE, uname = "", pwd = "", encoding = "UTF-8", qry = "" )
url |
The '[kpi-url]' of kobotoolbox. Default is "eu.kobotoolbox.org" |
simplified |
A logical value, default is true |
uname |
takes the username |
pwd |
takes the password |
encoding |
is the encoding to be used. Default is "UTF-8". |
qry |
to add queries |
The function takes two variables. First one is 'url' which is the '[kpi-url]'. For most users it will be "eu.kobotoolbox.org" or "kf.kobotoolbox.org". Former is the default. The second parameter is 'simplified' which takes a logical value. If set to true, the function will return selected values from the parsed data and return a data frame. When set to false, a json will be returned with all the details.
The function returns the asset details from the API, inform of a data frame or json.
'kobotools_kpi_data' is a wrapper for kobotoolbox API 'https://[URL]/api/v2/assets/[assetid]/data/'
kobotools_kpi_data( assetid, url = "eu.kobotoolbox.org", uname = "", pwd = "", encoding = "UTF-8", format = "json" )
kobotools_kpi_data( assetid, url = "eu.kobotoolbox.org", uname = "", pwd = "", encoding = "UTF-8", format = "json" )
assetid |
is the asset id of the asset for which the data is to be downloaded. The id can be found by running [kobotools_data_list_kc()] |
url |
The '[kpi-url]' of kobotoolbox. Default is "eu.kobotoolbox.org" |
uname |
is username of your kobotoolbox account |
pwd |
is the password of the account |
encoding |
is the encoding to be used. Default is "UTF-8". |
format |
lets you define the format of output for e.g. json or xml |
The function takes the url as one of the inputs. And asset id as another. Both are strings. The asset id is found by running the [kobotools_api()] function.Other parameters are username and password.
The function returns the data in json format