Can I use the Import Wizard to open files that are partially in ASCII format and partly in binary format?

1 view (last 30 days)
I have a data file with header lines that are in ASCII format and the data in binary format. I would like to use the Import Wizard to open such files and appropriately retrieve the binary formatted data.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 21 Oct 2021
Edited: MathWorks Support Team on 21 Oct 2021
The ability to interpret data files that are partly in ASCII format and partly in binary format is not available with the MATLAB Import Wizard. To work around this issue, use the MATLAB file I/O functions to read and interpret such data files. For a complete list of file I/O functions in MATLAB, please refer to the following documentation page:
The following example code reads a file that has a few header lines in ASCII format using the FGETL function and then reads the subsequent binary formatted data using the FREAD function.
function [hdr,data] = myBinaryReader(filename,headerlines)
hdr = [];
fid = fopen(filename,'r');
for(i=1:1:headerlines)
hdr{i} = fgetl(fid);
end
data = fread(fid);
fclose(fid)

More Answers (0)

Categories

Find more on Data Import and Analysis in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!