From 6e865cd963866c81209c465a97fe037c0f3a7e01 Mon Sep 17 00:00:00 2001 From: Eitan Hemed <37670372+EitanHemed@users.noreply.github.com> Date: Tue, 30 May 2023 22:57:35 +0300 Subject: [PATCH 1/8] Update ExperimentHandler.js Adding to ExperimentHandler a field separator property, which allows output to include field separators other than comma (e.g., TSV format). --- src/data/ExperimentHandler.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/data/ExperimentHandler.js b/src/data/ExperimentHandler.js index 2c2bebc9..bfaa5443 100644 --- a/src/data/ExperimentHandler.js +++ b/src/data/ExperimentHandler.js @@ -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(); From 1f1566f53c4737b63ca6ef432d38c08c05abf304 Mon Sep 17 00:00:00 2001 From: Eitan Hemed <37670372+EitanHemed@users.noreply.github.com> Date: Tue, 30 May 2023 23:00:30 +0300 Subject: [PATCH 2/8] Update ExperimentHandler.js Fixed type in this._field_separator --- src/data/ExperimentHandler.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/data/ExperimentHandler.js b/src/data/ExperimentHandler.js index bfaa5443..096388e2 100644 --- a/src/data/ExperimentHandler.js +++ b/src/data/ExperimentHandler.js @@ -81,9 +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._field_separator = (typeof extraInfo.field_separator === "string" || extraInfo.field_separator.length === 1 || extraInfo.field_separator !== '\n') + ? extraInfo.field_separator + : ','; this._addAttribute( "dataFileName", @@ -294,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, FS=this._field_seperator); + 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(); From f1d05c8c940b9ea841330a72cfc212cbb61c1868 Mon Sep 17 00:00:00 2001 From: Eitan Hemed <37670372+EitanHemed@users.noreply.github.com> Date: Tue, 30 May 2023 23:03:45 +0300 Subject: [PATCH 3/8] Update ExperimentHandler.js Passing parameters correctly to .sheet_to_csv --- src/data/ExperimentHandler.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/data/ExperimentHandler.js b/src/data/ExperimentHandler.js index 096388e2..aef0fa6d 100644 --- a/src/data/ExperimentHandler.js +++ b/src/data/ExperimentHandler.js @@ -294,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, FS=this._field_separator); + 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(); From 6245c380eff938c88f6f873bdc78d58ea4dc75cb Mon Sep 17 00:00:00 2001 From: Eitan Hemed <37670372+EitanHemed@users.noreply.github.com> Date: Sat, 24 Jun 2023 08:37:26 +0000 Subject: [PATCH 4/8] Revert "Update ExperimentHandler.js" This reverts commit f1d05c8c940b9ea841330a72cfc212cbb61c1868. --- src/data/ExperimentHandler.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/data/ExperimentHandler.js b/src/data/ExperimentHandler.js index aef0fa6d..096388e2 100644 --- a/src/data/ExperimentHandler.js +++ b/src/data/ExperimentHandler.js @@ -294,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, {FS: this._field_separator}); + 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(); From c660feac1d75894e7a81c60e343a357630fb0d4c Mon Sep 17 00:00:00 2001 From: Eitan Hemed <37670372+EitanHemed@users.noreply.github.com> Date: Sat, 24 Jun 2023 08:37:38 +0000 Subject: [PATCH 5/8] Revert "Update ExperimentHandler.js" This reverts commit 1f1566f53c4737b63ca6ef432d38c08c05abf304. --- src/data/ExperimentHandler.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/data/ExperimentHandler.js b/src/data/ExperimentHandler.js index 096388e2..bfaa5443 100644 --- a/src/data/ExperimentHandler.js +++ b/src/data/ExperimentHandler.js @@ -81,9 +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._field_seperator = (typeof extraInfo.field_seperator === "string" || extraInfo.field_seperator.length === 1 || extraInfo.field_seperator !== '\n') + ? extraInfo.field_seperator + : ','; this._addAttribute( "dataFileName", @@ -294,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, FS=this._field_separator); + 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(); From b67f9943a33885498bb667474aa0d93c49ca7a8a Mon Sep 17 00:00:00 2001 From: Eitan Hemed <37670372+EitanHemed@users.noreply.github.com> Date: Sat, 24 Jun 2023 08:42:46 +0000 Subject: [PATCH 6/8] Revert "Update ExperimentHandler.js" This reverts commit 6e865cd963866c81209c465a97fe037c0f3a7e01. --- src/data/ExperimentHandler.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/data/ExperimentHandler.js b/src/data/ExperimentHandler.js index bfaa5443..2c2bebc9 100644 --- a/src/data/ExperimentHandler.js +++ b/src/data/ExperimentHandler.js @@ -81,9 +81,6 @@ 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", @@ -294,7 +291,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, FS=this._field_seperator); + const csv = "\ufeff" + XLSX.utils.sheet_to_csv(worksheet); // upload data to the pavlovia server or offer them for download: const filenameWithoutPath = this._dataFileName.split(/[\\/]/).pop(); From c657ad6ee2e842856a98bd30ff1a66ef84f5e0d0 Mon Sep 17 00:00:00 2001 From: Eitan Hemed <37670372+EitanHemed@users.noreply.github.com> Date: Sat, 24 Jun 2023 09:00:22 +0000 Subject: [PATCH 7/8] Assigning field_separator as parameter of ExperimentHandler --- src/data/ExperimentHandler.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/data/ExperimentHandler.js b/src/data/ExperimentHandler.js index 2c2bebc9..9dd48f2e 100644 --- a/src/data/ExperimentHandler.js +++ b/src/data/ExperimentHandler.js @@ -56,12 +56,14 @@ export class ExperimentHandler extends PsychObject * @param {module:core.PsychoJS} options.psychoJS - the PsychoJS instance * @param {string} options.name - name of the experiment * @param {Object} options.extraInfo - additional information, such as session name, participant name, etc. + * @param {string} field_separator - Delimiter character specification */ constructor({ psychoJS, name, extraInfo, - dataFileName + dataFileName, + field_separator } = {}) { super(psychoJS, name); @@ -98,6 +100,12 @@ export class ExperimentHandler extends PsychObject this._currentTrialData = {}; this._experimentEnded = false; + + // assign output delimiter character + this.field_separator = (typeof field_separator === "string" || field_separator.length === 1 || field_separator !== '\n') + ? field_separator + : ','; + } /** @@ -291,7 +299,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(); From 6c7e8cf29f8f7f6c71db684ada453efae3868eec Mon Sep 17 00:00:00 2001 From: Eitan Hemed <37670372+EitanHemed@users.noreply.github.com> Date: Sat, 24 Jun 2023 12:38:28 +0000 Subject: [PATCH 8/8] Properly using the _addAttribute method --- src/data/ExperimentHandler.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/data/ExperimentHandler.js b/src/data/ExperimentHandler.js index 9dd48f2e..5910611d 100644 --- a/src/data/ExperimentHandler.js +++ b/src/data/ExperimentHandler.js @@ -90,6 +90,13 @@ export class ExperimentHandler extends PsychObject `${this._participant}_${this._experimentName}_${this._datetime}` ); + this._addAttribute("field_separator", + (typeof field_separator === "string" || field_separator.length === 1 || field_separator !== '\n') + ? field_separator + : ',', + ',' + ); + // loop handlers: this._loops = []; this._unfinishedLoops = []; @@ -101,11 +108,7 @@ export class ExperimentHandler extends PsychObject this._experimentEnded = false; - // assign output delimiter character - this.field_separator = (typeof field_separator === "string" || field_separator.length === 1 || field_separator !== '\n') - ? field_separator - : ','; - + } /**