From b6dd272b6a00f116e13ae67bb3c652557be2a5e5 Mon Sep 17 00:00:00 2001
From: Thomas Lambert <t.lambert@uliege.be>
Date: Sun, 11 Dec 2022 01:41:38 +0100
Subject: [PATCH] feat(save): add overwrite option

---
 utils/savecsv.m | 6 ++++--
 utils/savemat.m | 4 +++-
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/utils/savecsv.m b/utils/savecsv.m
index 544a88e..6a9f745 100644
--- a/utils/savecsv.m
+++ b/utils/savecsv.m
@@ -20,6 +20,8 @@ function savecsv(ExpData, arduShort, tunnelData)
                            'Fx2', 'Fy2', 'Fz2', 'Mx2', 'My2', 'Mz2'};
     SAMPLING = 1000;
 
+    ALWAYS_OVERWRITE = true;
+
     if isempty(arduShort)
         tableHeader = STATIC_TABLE_HEADER;
         time = (0:1 / SAMPLING:(size(tunnelData, 1) - 1) / SAMPLING)';
@@ -36,12 +38,12 @@ function savecsv(ExpData, arduShort, tunnelData)
                        testCase, ExpData.dx * 100, ExpData.freq, ExpData.airspeed);
     savefile = fullfile('data/cleaned', dirSplits(1), filename);
 
-    if ~exist(string(savefile), 'file')
+    if ~exist(string(savefile), 'file') || ALWAYS_OVERWRITE
         % Merges the two arrays together and put it in table
         size(time);
         size(arduShort);
         size(tunnelData);
-        cleanedArray = [time, arduShort, tunnelData];
+        cleanedArray = [time, arduShort(:, 2:end), tunnelData];
         cleanedTable = array2table(cleanedArray, ...
                                    'VariableNames', tableHeader);
 
diff --git a/utils/savemat.m b/utils/savemat.m
index d592c11..32cce18 100644
--- a/utils/savemat.m
+++ b/utils/savemat.m
@@ -10,12 +10,14 @@ function savemat(idFile, ExpData)
     % MIT License
     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
+    ALWAYS_OVERWRITE = true;
+
     % Make filename
     [~, file, ~] = fileparts(idFile);
     savedir = strsplit(file, '-');
     savefile = fullfile('data/cleaned_MAT', savedir(1), [file, '.mat']);
 
-    if ~exist(string(savefile), 'file')
+    if ~exist(string(savefile), 'file') || ALWAYS_OVERWRITE
         save(string(savefile), 'ExpData');
     end
 end
-- 
GitLab