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

NF: Adding field seperator selection in output #566

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
5 changes: 4 additions & 1 deletion src/data/ExperimentHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ export class ExperimentHandler extends PsychObject
this._datetime = (typeof extraInfo.date !== "undefined")
? extraInfo.date
: MonotonicClock.getDateStr();
this._field_separator = (typeof extraInfo.field_separator === "string" || extraInfo.field_separator.length === 1 || extraInfo.field_separator !== '\n')
? extraInfo.field_separator
: ',';

this._addAttribute(
"dataFileName",
Expand Down Expand Up @@ -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_separator});

// upload data to the pavlovia server or offer them for download:
const filenameWithoutPath = this._dataFileName.split(/[\\/]/).pop();
Expand Down