How to extract string/numbers after a keyword in a text
Mostra commenti meno recenti
Hi,
I have a text like the following.
z
>HEAD
DATAID="P=01 R=14 (H)"
ACQBY="DGSM"
FILEBY=""
ACQDATE=04/11/22
ENDDATE=04/13/22
FILEDATE=02/16/23
COUNTRY="UG"
LAT=3:26:1.6
LONG=30:56:25.9
ELEV=1224.44
UNITS=M
STDVERS="SEG 1.0"
PROGDATE="10/20/20"
EMPTY=1.0E32
>INFO MAXINFO=108
UNIQUE ID: {fd652be6-76e5-476d-ace0-bf2981887cf2}
PROCESS DATE: 2022-06-29 18:13
DURATION: 38 h 36 m 20 s
DECLINATION: 2°
...
...
How to extract the corresponding value after a given keyword? For instance, I would like to have
keyword = "LAT"
lat = [3,26,1.6];
keyword = "ACQDATE"
date = 04/11/22;
keyword = "EMPTY"
emptyval = 1.0E32;
keyword = "UNIQUE ID"
uid = 'fd652be6-76e5-476d-ace0-bf2981887cf2';
...
Would there be a function that can take care of all types of values?
Thanks,
Jasmine
2 Commenti
the cyclist
il 30 Mag 2023
Modificato: the cyclist
il 30 Mag 2023
Can you upload the text file? You can use the paper clip icon in the INSERT section of the toolbar.
Also, can you be more specific about what you need? For example, do you just want to input a keyword, and have MATLAB store/output the corresponding value? Or, do you want MATLAB to figure out all the keyword-value pairs and store them?
Jasmine Zhu
il 30 Mag 2023
Risposta accettata
Più risposte (1)
You might like to know about dictionary
help dictionary
Categorie
Scopri di più su String Parsing in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!