How do I open a .raw file so that it can be viewed as a table?
48 ビュー (過去 30 日間)
古いコメントを表示
I have this .raw file that I would like to open in as a table so I can then further process the data. I currently have to open the file using excel and then import the excel file as a table into matlab, but I want to cut out that step. (Also, I have code written to clean up the table once it's in matlab, so I'm not worried if the import has a bunch of NaN values). I can't attach the .raw file becase matlab doesn't support the format so I'm attaching the excel file.
%% Import data and convert excel file to a struct
% Input the .xlsx file in the function below
T = readtable('OS-1-69-B1-HT.is_comp.xlsx');
% Rectify and organize data
row_valid = ~reshape(ismissing(T(:,1)), 1 , []);
starts = strfind([false row_valid], [false true ]);
stops = strfind([row_valid, false], [true false]);
sub_tables = arrayfun(@(B,E) T(B:E,:), starts, stops, 'uniform', 0);
% Convert the table to a struct
Data = struct();
for i = 1:length(sub_tables)
Data.(sprintf('Specimen%d',i)) = sub_tables{i};
end
3 件のコメント
採用された回答
Cris LaPierre
2022 年 1 月 15 日
編集済み: Cris LaPierre
2022 年 1 月 17 日
Consider starting with this:
T = readtable("OS-1-69-B1-HT.is_comp.raw",'Delimiter',{'"',','},...
'FileType','text','numHeaderLines',94)
Add your code, and it appears the result is the same (though not checked exhaustively)
3 件のコメント
Charles
2024 年 2 月 16 日
How would you go about modifying this code to read through a folder of raw data and output spreadsheets for each file?
This code works well for individual files, but I need to automate the process for new data, so typing the individual file names is not efficient.
Cris LaPierre
2024 年 2 月 16 日
Do you need a separate spreadsheet for each file? If so capture the file names in an array (I'd use dir), then place the code inside a for loop so that it runs the code for each file.
In both cases, use writetable to write the data to a spreadsheet.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Tables についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!