Help with readtable opts
이전 댓글 표시
I have some data (example attached).
I am using a readtable for loop to combine multiple CSV files in to one dataset which I can process. This works great.
d = uigetdir; %Select folder containing logger data
filePattern = fullfile(d, '*.csv'); %naming convention of file.
filedir = dir(filePattern); %directory of all files with .csv extension
Q=numel(filedir);
x = cell(1, Q);
%numel(filedir) returns number of items in filedr (how many files will be processed
for k = 1 : Q
baseFileName = filedir(k).name; %calls file name from position k in firdir
fullFileName = fullfile(d, baseFileName); %concatenate file directory and baseFileName to give full absolute path
x{k} = readtable(fullFileName); %imports data from csv
fprintf('read file %s\n', fullFileName); %show which file is being processed in command window
end
bigtable = vertcat(x{:}); %Add individual data sets together to make one large test data set
I have tried to use the following code to specify the units row and where the data starts.
%before for loop
opts.VariableNamesLine = 1;
opts.VariableUnitsLine = 2;
opts.DataLine = 4;
%inside for loop
x{k} = readtable(fullFileName,opts)
The DataLine seems to work and it ignores the first 3 lines. However I longer have variables and units.
The other problem I have is that readtable makes everything a string rather than a double. (This is my biggest problem as I can't process the data, please help!)
Thanks
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Spreadsheets에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!