How can I extract infroamtion from a header's file (text file)?
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (1)
Radha Krishna Maddukuri
il 9 Giu 2015
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 Commenti
Vedere anche
Categorie
Scopri di più su Environment and Settings in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!