reading out a particular column with a header name from a large text file with multiple rows and columns. of different dimensions. Attached the .txt file.

조회 수: 1 (최근 30일)
I couldnot find a solution for reading out a particular column with a header name in text file with multiple row and columns of different dimensions. Attached the .txt file for reference. The intention is to read out all the numbers under the column header name N482.
I would appreciate the help!
Smruti

채택된 답변

Mathieu NOE
Mathieu NOE 2021년 9월 28일
hello
I am not sure if you ask for the data in the N482 rows (and not column) as we can see in the first 49,407 lines of your data file
or if we are talking about some columns in the very lower end of the data file where N482 also sometimes appear but seems asociated with many different variables
in case the good answer is correponding to the first scenario, here a little code that will retrieve the data :
clc
clearvars
%%% main code %%%
[ data_out ] = retrieve_data('PerformanceResults.txt');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [ data_out ] = retrieve_data(Filename)
fid = fopen(Filename);
tline = fgetl(fid);
% initialization
k = 0;
p = 0;
data_line = [];
while ischar(tline)
k = k+1; % loop over line index
tmp1 = contains(tline,'N482:');
if tmp1 && ~isempty(tline)
p = p+1;
ind1 = strfind(tline,':');
ind2 = strfind(tline,'[');
data_out(p,1) = str2double(tline(ind1+1:ind2-1)); %
end
tline = fgetl(fid);
end
fclose(fid);
end
  댓글 수: 4
smruti sahoo
smruti sahoo 2021년 9월 28일
Hello Mathieu,
I need to read data from the row 49428 untill 49574 for "N481 " and "PWX481". It would be great if the data column also accompanies the respective subset as mentioned between the tags such as "Top of Climb" , "Cruise" etc. .
Best Regards,
Smruti
Mathieu NOE
Mathieu NOE 2021년 9월 28일
hello
ok but I still have a few questions , like
N481 , no more N482 ?
when i search for N481 in the specified rows , I can find it under different variables / units like :
EF1.Ncrel
N481
[-]
________________________
0.1000000000000000E+01
0.9162897600284080E+00
0.7497359606957799E+00
0.8814135438000129E+00
EFAN1Shaft.N
N481
[rpm]
_______________________
0.8000000000000000E+04
0.7168221667751842E+04
0.6176755811549974E+04
0.7745871554961489E+04
EF1.Ncrel
N481
[-]
_______________________
0.1000000000000000E+01
0.9162897600284080E+00
0.7497359606957799E+00
0.8814135438000129E+00
EFAN1Shaft.N
N481
[rpm]
________________________
0.8000000000000000E+04
0.7168221667751842E+04
0.6176755811549974E+04
0.7745871554961489E+04
EF1.Ncrel
N481
[-]
_______________________
0.1000000000000000E+01
0.9162897600284080E+00
0.7497359606957799E+00
0.8814135438000129E+00
EFAN1Shaft.N
N481
[rpm]
______________________
0.8000000000000000E+04
0.7168221667751842E+04
0.6176755811549974E+04
0.7745871554961489E+04
EF1.Ncrel
N481
[-]
_______________________
0.1000000000000000E+01
0.9162897600284080E+00
0.7497359606957799E+00
0.8814135438000129E+00
and so on...
how do I have to understand how we organize the retrieval of data ? we cannot simply put together what is different topic
for PWX481 same question

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

추가 답변 (1개)

smruti sahoo
smruti sahoo 2021년 9월 28일
Hello,
N481 and N482 have the same value per se. As you rightly mentioned I would be intrested in extarcting the real value of N481 which is folowed by "rpm". The PWX481 with 'W' as in watt is desired to be retrieved. I wish to save the retrived data in matrix for further compilation. So that I can read the particular column.
thanks,
Smruti
  댓글 수: 3
smruti sahoo
smruti sahoo 2021년 9월 28일
Hello Mathieu,
That was a great work, To say thank you would be less!
Best regards,
Smruti

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by