1
0
mirror of https://github.com/psychopy/psychojs.git synced 2025-05-11 16:18:10 +00:00

Update ExperimentHandler.js

Adding to ExperimentHandler a field separator property, which allows output to include field separators other than comma (e.g., TSV format).
This commit is contained in:
Eitan Hemed 2023-05-30 22:57:35 +03:00 committed by GitHub
parent 941b4425b9
commit 6e865cd963
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -81,6 +81,9 @@ export class ExperimentHandler extends PsychObject
this._datetime = (typeof extraInfo.date !== "undefined")
? extraInfo.date
: MonotonicClock.getDateStr();
this._field_seperator = (typeof extraInfo.field_seperator === "string" || extraInfo.field_seperator.length === 1 || extraInfo.field_seperator !== '\n')
? extraInfo.field_seperator
: ',';
this._addAttribute(
"dataFileName",
@ -291,7 +294,7 @@ export class ExperimentHandler extends PsychObject
// TODO only save the given attributes
const worksheet = XLSX.utils.json_to_sheet(data);
// prepend BOM
const csv = "\ufeff" + XLSX.utils.sheet_to_csv(worksheet);
const csv = "\ufeff" + XLSX.utils.sheet_to_csv(worksheet, FS=this._field_seperator);
// upload data to the pavlovia server or offer them for download:
const filenameWithoutPath = this._dataFileName.split(/[\\/]/).pop();