How can I convert .000 and .002 files into files that I can understand and work with MATLAB

조회 수: 13 (최근 30일)
Hello everyone,
I'm a studient of Marine Science and I'm new with programming and working with different types of files.
I have pressure and wave data from loggers. The files I've got, have the extension .000 and .002.
For example:
21033018.000
21033018.002
21033020.000
21033020.002
21033022.000
21033022.002
...
When I open those files with Notepad++, Excel or other softwares the content is unredable, that is, the written content is in an incomprehensible "language" with symbols.
I want to know how can I get the readable data. Data that I can read and understand with numbers, so I can work with toolboxes for MATLAB. How can I convert those files in files like .csv or .txt that have the understandable data.
Thanks in advance for your attention,
Guillermo
  댓글 수: 6
Walter Roberson
Walter Roberson 2022년 8월 11일
If you could execute this and show us the result, it might help us identify the file
fid = fopen('21033018.000', 'r');
f64 = fread(fid, [1 64], '*uint8');
fclose(fid);
fprintf('header as character:\n');
fprintf('%c', f64);
fprintf('\n');
fprintf('\nheader as decimal:\n');
fprintf('%03d ', f64);
fprintf('\n');
fprintf('\nheader as hex:\n');
fprintf('%02x ', f64);
fprintf('\n');

댓글을 달려면 로그인하십시오.

답변 (1개)

Gagan Agarwal
Gagan Agarwal 2023년 9월 7일
Hi Guillermo Carballo Lafuente
You can refer to the sample code snippet below to convert the files into a format that is compatible with MATLAB, allowing you to work with them within the MATLAB environment.
files = dir('*.002');
% Loop through each file
for id = 1:length(files)
% Get the file name (minus the extension)
orig_name = files(id).name;
[~, basename, ext] = fileparts(orig_name);
new_name = [basename '_', ext(2:end) '.txt'];
movefile(orig_name, new_name);
end
The above code snippet converts files with the extension '.002' to '.m' files. Similarly, you can convert files with the extension '.000' and ‘.002’ to any desired format by modifying the 'new_name' variable in the code.
  댓글 수: 1
Walter Roberson
Walter Roberson 2023년 9월 7일
This will not help. @Guillermo Carballo Lafuente tried opening them with a text editor and found them to be unreadable to humans, which indicates that they are binary files. Renaming binary files does not make them any more usable to MATLAB.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Low-Level File I/O에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by