How can I extract infroamtion from a header's file (text file)?
6 ビュー (過去 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 で Text Data Preparation についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!