At the beginning of the online experiment, I loaded a .csv file stored in the GitLab repo using a code component. Next, I modify the .csv file for a complex pseudo randomization routine.
Now I would like to save the modified .csv file to the Gitlab repo such that when the next participant starts the experiment, the modified .csv file can be loaded.
However, I was not able to achieve this.
Therefore, three questions:
- Is it possible to save a .csv file directly into the Gitlab repo
- Could I use [Shelf] to do so?
- How to achieve this in javascript?
I’m really not used to javascript – my humble attempt at the moment is as follows:
const csvFilePath = '/some/path/some_file.csv';
// Load the CSV file using PapaParse
Papa.parse(csvFilePath, {
header: true,
download: true,
complete: function(results) {
const tripletInfo = results.data;
// Do stuff --> modify the .csv file
...
// Save the modified data to a CSV file using PapaParse
const csvData = Papa.unparse(tripletInfo);
const csvBlob = new Blob([csvData], { type: 'text/csv;charset=utf-8;' });
const csvUrl = URL.createObjectURL(csvBlob);
const downloadLink = document.createElement('a');
downloadLink.href = csvUrl;
downloadLink.download = csvFilePath;
document.body.appendChild(downloadLink);
downloadLink.click();
document.body.removeChild(downloadLink);
}
});
Thanks in advance!