Reading Text file from IMC company

13 views (last 30 days)
Aubai on 31 May 2021
Edited: Jan on 28 Jul 2021
Dear All,
I am trying to read .raw files created by IMC measurement devices (basically it is a Text file). for that i am using the following code:
fid = fopen(FullRawData,'r');
And in most cases it is working yet in some cases Matlab is not reading the correct text data. E.g.:
When showing the .raw file in WordPad:
|CF,2,1,1;|CK,1,3,1,1;|NO,1, 91,0,83,imc STUDIO 5.2 R13 (02.01.2020)@imc DEVICES 2.13R4 (2020-01-13)@imcDev__16200173@PC,0,;|NL,1, 8,1252,0x0;|CG,1, 5,1,1,1;|CD,2, 65, 2.000000000000000e-004,1,1,s,0,0,0, 0.000000000000000e+000,1;|NT,1, 14,1,1,1980,0,0,0;|CC,1, 3,1,1;|CP,1, 16,1,2,4,16,0,0,1,0;|CR,1, 59,1, -3.051944088384301e-001, 0.000000000000000e+000,1,1,A;|ND,1, 63, -1, -1, -1, 0.000000000000000e+000, 0.000000000000000e+000;|Np,1, 399,"imc1000" "Analog" 0 0,"imc1058" "200173" 0 0,"imc07" "0" 4 0,"ExpGuid" "d5c3232f-2ecd-4433-83eb-8688a4163b82" 0 0,"ORIGINALDATAPATH" "D:xxxxxxx\I3_Netz.raw " 0 0;|CN,1, 18,0,0,0,7,I3_Netz,0,;|Cb,1, 124, 1,0, 1, 1,0, 6000000, 0, 6000000,1, 2.216397344000004e+005, 1.296383160265600e+009,;|CS,1, 6000011, 1,æ
which is ok as i expected. Yet in matlab the Texall looks like this:
Aubai on 31 May 2021
Hallo Rik,
Even when opening the file in normal standard Notepad i am still getting the expected file format (header) and when opining the file in FAMOS-Software (from the IMC-manufacutrer) there is no error or nothing.
Unfortionatily i already tried this and no replay.
Best Regards

Sign in to comment.

Accepted Answer

Aubai on 28 Jul 2021
so i solve it by using different functions till i get the answer:
here is the code if anyone out there is interested in that
fid1 = fopen(FullRawData,'r','a','US-ASCII');
tline = fgets(fid1);
Aubai on 28 Jul 2021
It is working for me as i need the header first and then i extract infromation of what to read afterword.
yes i did not close this as i just wanted to show what options i used.

Sign in to comment.

More Answers (1)

Jan on 31 May 2021
Edited: Jan on 28 Jul 2021
From a certain byte in the text the contents is not plain ASCII anymore. I guess boldly, that this was a problem during writing the data. If this is the case, there is no chance to repair the file afterwards.
Rik on 31 May 2021
The function you linked to assumes everything in this file is plain ASCII. It is not. You can clearly see this if you open the file with Notepad++. You might be able to circumvent this by loading the file as uint8 and then casting to char. That will avoid Matlab from interpreting the file, which might be the part causing issues.
The main point is that the assumption is false: the file contains data that is not plain text. Any function based on that assumption is doomed to fail.

Sign in to comment.


Find more on Startup and Shutdown in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by