How can I convert .000 and .002 files into files that I can understand and work with MATLAB
15 次查看(过去 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
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');
Sri Adiyanti
2023-4-18
Hi, Iif they are raw binary file from RD ADCP data, try: GitHub - Cody-Benton/ADCP_Processing: Code processes binary ADCP data and incorporates some quality control measures.
回答(1 个)
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
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 Center 和 File Exchange 中查找有关 Data Type Conversion 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!