-
Notifications
You must be signed in to change notification settings - Fork 1
/
exportCSVs.m
37 lines (29 loc) · 891 Bytes
/
exportCSVs.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
% exportCSVs loads all available MEF and exports them as CSV
function exportCSVs(pathToLoad)
if nargin < 1
pathToLoad = 'data/human/';
end
mkdir([pathToLoad 'csv']);
addpath import;
files = dir([pathToLoad '*.xlsx']);
for file = files'
disp(['Writing ' file.name '...']);
[~, name, ext] = fileparts(file.name);
[values, participants, measures] = mefimport([pathToLoad name ext]);
% Get rid of any commas
measures = strrep(measures, ',', ';');
participants = strrep(participants, ',', ';');
outputpath = [pathToLoad 'csv/' name '.csv'];
fileID = fopen(outputpath, 'w');
% Print header row
fprintf(fileID, 'Participant');
fprintf(fileID, ',%s', measures);
fprintf(fileID, '\n');
for i = 1:length(participants)
fprintf(fileID, '%s', participants(i));
fprintf(fileID, ',%f', values(i, :));
fprintf(fileID, '\n');
end
end
rmpath import;
end