How do I open a .raw file so that it can be viewed as a table?

48 ビュー (過去 30 日間)
Cole Garabed
Cole Garabed 2022 年 1 月 14 日
コメント済み: Cris LaPierre 2024 年 2 月 16 日
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 件のコメント
Cole Garabed
Cole Garabed 2022 年 1 月 14 日
I didn't think of that. Here it is
Walter Roberson
Walter Roberson 2022 年 1 月 15 日
Which parts of the data do you need?

サインインしてコメントする。

採用された回答

Cris LaPierre
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
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
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.
If you want to combine all the data into a single spreadsheet, look into using a fileDatatStore.
In both cases, use writetable to write the data to a spreadsheet.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeTables についてさらに検索

タグ

製品


リリース

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by