cloudyr / limer

A LimeSurvey R Client
MIT License
67 stars 37 forks source link

get_responses() returns multiple observations but only one variable #53

Open wolass opened 5 years ago

wolass commented 5 years ago

Hi guys! Thanks for developing the package

I have encountered the following problem: Whenever I download the responses I get all the entries but in a strange format where all the columns are combined into one.

I tried to circumvent this using direct call using call_limer, but it basically gives me raw data which if I push to base64_to_df - gives just the same results as using get_response.

This guy has the same issue - so at least I'm not alone: https://stackoverflow.com/questions/51989013/trying-to-pull-down-data-in-r-from-limesurvey-its-failing-why

All the variables are squashed into one line with points as separators: as : q620.cortico_priorv5..q620.cortico_acute..q620.cortico_primcarev3..q620.cortico_centre..q620.cortico_no..q620.other_priorv5..q620.other_acute..q620.other_primcarev3..q620.other_centre..q620.other_no..q631autoinjbrandv7.q632autoinjnumberv7.q633autoinjdosisv7.qcommentv5 I have underscores in my variable names - could this be a problem?

This is my session info:

R version 3.5.1 (2018-07-02)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.10

Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.8.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.8.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=de_DE.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=de_DE.UTF-8    LC_MESSAGES=en_US.UTF-8    LC_PAPER=de_DE.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=de_DE.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] limer_0.1

loaded via a namespace (and not attached):
[1] httr_1.4.0      compiler_3.5.1  R6_2.4.0        tools_3.5.1     base64enc_0.1-3 curl_3.3        yaml_2.2.0      jsonlite_1.6  
s-bravo commented 4 years ago

Hi, did you solve this problem? I have the same problem with some installations of Limesurvey.

wolass commented 4 years ago

No I haven't .

FrdVnW commented 3 years ago

Hi there, I have the same issue. It seems linked to the version of Limesurvey (an old one here) : see this commit https://github.com/cloudyr/limer/commit/d7c0c3ecf4e2393045711622589165e75c3b5f4d#diff-c913239c7e28d0566d870ec92da5855c One easy solution could be to redefine locally :

base64_to_df <- function(x) {
  raw_csv <- rawToChar(base64enc::base64decode(x))

  return(read.csv(textConnection(raw_csv), stringsAsFactors = FALSE, sep = ","))
}

Then (ex.) :

raw_data <- call_limer(method = "export_responses", 
                       params = list(iSurveyID = survey.id, 
                                     sDocumentType = "csv", 
                                     sLanguageCode = "fr", 
                                     sCompletionStatus = "complete", 
                                     sHeadingType = "code", 
                                     sResponseType = "long"))

data <- base64_to_df(raw_data)