How can I extract infroamtion from a header's file (text file)?
조회 수: 7 (최근 30일)
이전 댓글 표시
I want extract information from a header file (see attachment). For instance I would like to save in an array or in variables the information such as, time, date, BeamVoltage, Filament, Temp, etc... so I can use these values later on or simply send them to a text box on a GUI.
I have tried several things but nothing really works for all since the format is not uniform at all, the information of interest sometimes comes after a ':' or a '=' or simple a ' '... Please help!!!.
Thanks, Alex
댓글 수: 0
답변 (1개)
Radha Krishna Maddukuri
2015년 6월 9일
First of all, there is no direct ways for reading values with different delimiters like '=' ':' 'space', etc.,
However, readtable is a good function for reading the values that you intend to. The second example in the following documentation is relevant to your use case.
However a slight modification is required to your file.
For example: create a file A.txt:
Beam Voltage (-kV) = 13.000
Filament (W) = 4.052
Wehnelt (-V) = 400.00
Cond. (-kV) = 8.685
CenterX1 (V) = 23.7
CenterY1 (V) = -47.9
Objective (OctupoleX = 0.0000
OctupoleY = 0.0000
Angle (deg) = 0.00
Stig = 0.00
Then navigate to the folder containing A.txt in MATLAB and execute the following command in MATLAB Command Window:
>> readtable('A', 'delimiter', '=')
You will be able to read the required data.
For automating the modification of TEXT files, the following MATLAB Answer might be helpful.
I hope this helps you.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Import and Export에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!