Re: Exporting results into multiple individual text files

198 views
Skip to first unread message

Elisa Filevich

unread,
Aug 13, 2018, 2:02:23 PM8/13/18
to Lara Bridge, JATOS
Hi Lara,

I forwarded your email to the JATOS mailing list, I hope you don't mind.
There is no way to extract one file per subject in JATOS currently. 
I can think of two options. First, you could change your R script (that's for sure the easiest).  Otherwise, if you are using JSON format, your file with the results for all your subjects will look like this
{data for subject 1}
{data for subject 2}
...
{data for subject n}
If you're on Linux or Mac it's easy to split the file into multiple ones on each newline, like this: https://unix.stackexchange.com/questions/74146/split-file-into-multiple-small-files-separate-by-the-newline-symbol

Hope this helps
Elisa
 



On 13. Aug 2018, at 2:58 PM, Lara Bridge <Lara....@mrc-cbu.cam.ac.uk> wrote:

Hello,
 
I was wondering whether it is possible to export the online results from Jatos into individual text files (1 text file per participant)? I can only see how to ‘export all’ –but this gives me one text file with all the data, which isn’t compatible with the R scripts that I currently have. The only way I have found how to do it is to download each participants data individually, but this is quite slow and prone to error. Any suggestions?
 
Thanks in advance,
Lara 
 
_________________________________

Lara Bridge | Research Assistant
MRC Cognition and Brain Sciences Unit
University of Cambridge
01223 273689

Becky Gilbert

unread,
Aug 15, 2018, 8:57:21 AM8/15/18
to JATOS
Hi Lara and Elisa,

I might be wrong, but I think when you 'export multiple' or 'export all' results, you get one line per subject AND component, right? I just checked this quickly with 2 subjects on a task with 3 components, and I got 6 lines in total. So I think you'd have to modify the script to check for the subject ID in the JSON in each line, and then split the file by subject accordingly. I think it would be risky to just separate the file according to a set number of lines/components without checking the IDs, in case someone didn't complete all components or reloaded a component and thus has more than the expected number of lines.

Best,
Becky

MagdaLena Matyjek

unread,
Aug 15, 2018, 9:20:55 AM8/15/18
to JATOS
Hi all,

I also struggled with extracting data in R from the 'export all' file, but I came up with a solution. It may not be the neatest one, but it works ;)

First I read the whole file
out <- readLines("./results_all.txt")
 
Then put all in a list
list1 <- as.list("","")
for (i in 1:length(out)) {
  if (!(out[i] == "")) {
  list1[i] = out[i]
  }
}
list1[sapply(list1, is.null)] <- NULL

Extract a dataframe for each component separately

no.of.components = 4
no.of.participants = length(list1)/no.of.components

( transform component 1 (subject_id) )
list2 <- rbind(fromJSON(list1[[1]]),fromJSON(list1[[1 + no.of.components]]))
for (i in 3:no.of.participants-1) {
  list2 <- rbind(list2,fromJSON(list1[[1 + no.of.components * i]]))
}

list3 <- rbind(fromJSON(list1[[2]]),fromJSON(list1[[2 + no.of.components]]))
for (i in 3:no.of.participants-1) {
  list3 <- rbind(list3,fromJSON(list1[[2 + no.of.components * i]]))
}

etc.

Then, if you need, you can merge the data frames by ID.
I'm sure there is a more elegant way, but if you're desperate, feel free to use my code :)

Best,
Lena

Elisa Filevich

unread,
Aug 17, 2018, 4:35:43 AM8/17/18
to JATOS
Thanks Becky for clarifying. Yes, you're right!

-- 
You received this message because you are subscribed to the Google Groups "JATOS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jatos+un...@googlegroups.com.
To post to this group, send email to ja...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jatos/da53a857-588a-4305-9eb9-5139a6df3f76%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Kristian Lange

unread,
Aug 17, 2018, 6:03:06 AM8/17/18
to ja...@googlegroups.com
Hi all,

I was just thinking, would it be helpful in this case to have the option to download each study result in its own file? Then each subject's study run would have their own file with all component results. And since browsers do not natively support multiple file downloads I would zip them all into one file. On the down side this could potentially lead to many files which can make things confusing. And there is an additional step in the GUI: select one or multiple files, and there is an additional step on the local computer, unzipping - makes it less convenient to use.

Any opinions?

Best,
Kristian

Becky Gilbert

unread,
Aug 22, 2018, 11:24:59 AM8/22/18
to JATOS
Hi Kristian,

Sorry for the delay (I'm still on maternity leave).

I think the option to download multiple results as separate files would be really useful. I write data processing pipelines that are designed for a single participant, so I need the data in a form that can be iterated through by participant, and separate files are great for that. I also like to have separate files per participant anyway so that I can easily go back and analyse data from a particular participant or subset of participants. So I don't use the 'export multiple' or 'export all' options because then I'd have to separate the lines by participant ID, which is tricky for the reasons I mentioned before. Instead I download each participant/result file individually (which is tedious). I can see your point about the downsides of adding this option to the JATOS GUI though - more GUI buttons, produces lots of files, having to unzip etc. But for me, this option would make things easier.

Anyway this is just my opinion and I might be in the minority! I'd be interested to know what other people think.

Becky

Kristian Lange

unread,
Aug 23, 2018, 2:25:59 PM8/23/18
to ja...@googlegroups.com
Hi Becky,
maybe I can find a way to reduce additional clicking in the GUI. Let me think about it.
Best
Kristian


Reply all
Reply to author
Forward
0 new messages