Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kobotools_api error retrieving ID #17

Open
rkopper-wv opened this issue May 10, 2023 · 5 comments
Open

kobotools_api error retrieving ID #17

rkopper-wv opened this issue May 10, 2023 · 5 comments

Comments

@rkopper-wv
Copy link

rkopper-wv commented May 10, 2023

Hello,

I was wondering if anyone encountered the following issue. When running the kobotools_api function to retrieve the list of assets IDs, I am receiving this error:
Downloading: 260 kB Error in parsed$results[[i]] : subscript out of bounds

I tried the kobotools_api function with another account that has less data (surveys and submissions) and it worked. I am thinking that perhaps my kobo account has too much data on it for the function to handle. Before I delete some archived data, I was wondering if others have encountered this issue and found some solutions. Or if deleting is the only solution, how much would I need to delete??

I am using:
kobotools_api(url="kobo.humanitarianresponse.info", simplified=T, uname="username", pwd=pw)
#username is actually replaced with my username*

If I set simplified to F then I can actually download the asset IDs but it comes in the form of a large list (4 elements)

Thanks

@asitav-sen
Copy link
Owner

Hi @rkopper-wv ,
Apologies for the delay. Could you resolve the issue?

@rkopper-wv
Copy link
Author

No, I used the alternate method of getting a simplified list then manually going into retrieve asset IDs that are embedded in the large list of elements.

@asitav-sen
Copy link
Owner

Is it possible to include the method in the code? What was the root cause of the issue?

@rkopper-wv
Copy link
Author

rkopper-wv commented Jul 18, 2023

I just tried it again and this was the error Downloading: 240 kB Error in parsed$results[[i]] : subscript out of bounds

I believe the issue stems from having so many assets as I tried the process with another kobo account, and it worked as usual.

My work around was:

# Check for ids from the list of assets 
id <- kobotools_api(url="kobo.humanitarianresponse.info", simplified=F, uname="username", pwd=pw)

# this results in a large list so i then work to track down and extract asset IDs


id[["results"]]-> cutd

ids <- lapply(1:length(cutd), function(i) {
  cutd[[i]][["uid"]] %>% 
    data.frame()
}) %>% 
  bind_rows()

names(ids) <- "uid"
ids$lst <- seq_along(ids[,1])

snames <- lapply(1:length(cutd), function(i) {
  cutd[[i]][["name"]] %>% 
    data.frame()
}) %>% 
  bind_rows()

names(snames) <- "name"
snames$lst <- seq_along(snames[,1])

df_list <- list(ids,snames)

#merge all data frames in list
df_list <- Reduce(function(x, y) merge(x, y, all=TRUE), df_list)
df_list2 <- df_list
##find  surveys from df

sixmon <- df_list2 %>%
  filter(str_detect(name, "insert text"))

sixmonc <- sixmon %>%
  filter(str_detect(name, "insert text"))

@asitav-sen
Copy link
Owner

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants