Anyone with a solution to the problem of pulling data with KoboconnectR

I have been using KoboconnectR package in R to export and import data from my Kobotoolbox account to my R workspace in R-Studio.

In the past it worked really well and I was able to pull data without any problems but for the past 2 months, I have been having timeout issues. I have searched and tried all suggested solutions but have not had any success. Here is the code below incase anyone has a solution:

library(KoboconnectR)

# get api (shows list of surveys created in the kobo account)

api <- kobotools_api(
  url = "kf.kobotoolbox.org",
  simplified = TRUE,
  uname = "username",
  pwd = "password",
  encoding = "UTF-8"
)


# csv data download (imports data into R working enviroment by creating an export in Kobo)
data.import <- kobo_df_download(
  url = "kf.kobotoolbox.org",
  uname = "username",
  pwd = "password",
  assetid = "assetid",
  all = "true",
  lang = "_default",
  hierarchy = "false",
  include_grp = "true",
  grp_sep = "/",
  fsep = ";",
  multi_sel = "both",
  media_url = "true",
  fields = NULL,
  sub_ids = NULL,
  sleep = 2
)

Downloading: 7.9 kB     Export instruction sent successfully. Waiting for result. 
Downloading: 7.9 kB     Execution in Progress...Timeout[1] "export creation was not successful"

Thank you.

I already tried increasing the sleep time, but still, it returns a timeout error.

Just wanted to clarify on that.

Welcome to the community, @echimwezi! Linking you with @dickoa for your support!

1 Like

@Kal_Lam Thank you for tagging @dickoa , I was able to follow one of his posts about using the robotoolbox package to pull data from Kobotoobox Introducing the R package robotoolbox - #58 by dickoa. I have been able to successfully pull data into R, and its working as a perfect alternative to the KoboconnectR package.

This is the final code I am using, just incase anyone might be interested to follow suit:

library(pacman)

p_load(robotoolbox, koboloadeR, dplyr)

# Get your authentication token
token <- kobo_token(
  username = "my_user_name",
  password = "my_password",
  url = "https://kc.kobotoolbox.org"
)

# Check kobo settings
kobo_setup(url = "https://kf.kobotoolbox.org", token = token)
kobo_settings()


# Get a list of all your kobo projects
l <- kobo_asset_list() 
head(l) 


# Select which project you want to pull data from
uid <- l$uid[1]
asset <- kobo_asset(uid)
asset

# Pull data
dsv_data <- kobo_data(asset)
glimpse(data)

Thanks once again. :blush:

2 Likes

@echimwezi this is great! I’m glad the tutorial/doc was enough to have you getting the data.
Ahmadou

2 Likes