extract from text file
Mostra commenti meno recenti
Hi, I am trying to use Matlab for this because I have ~300 files for which this needs to be done..
The data in the .txt file looks like this:
Event List
Patient Name: xyz Export Time: Thursday, April 11, 2013, 15:25:00 User Name: xyz Test ID: Name Time Duration Exam Start 00:00:00 00:00 Impedance - Impedance Values 00:00:00 00:00 Change - Montage Apply: 0bical.mtg 00:00:17 00:00 Calibration Off 00:00:18 00:00 Change - Montage Apply: 1doublebanana.mtg 00:00:36 00:00 . . .
I need a matrix file with 3 columns like this 00:00:00 00:00:00 Exam Start 00:00:00 00:00:00 Impedance - Impedance Values
i.e. 1) discard the first 7 lines.. 2) text goes into column 3 3) First values after text go into column 1 3) Second value + first value go into column 2
Is this possible?
Thanks, S
1 Commento
Cedric
il 25 Apr 2013
You seem to be saying that your data is not available in column (i.e. it is a stream of characters) but then you say that the first 7 lines have to be discarded, which seems to indicate that there is some structure.
Reading
Patient Name: xyz Export Time: Thursday, April 11, 2013, 15:25:00 User Name: xyz Test ID: Name Time Duration Exam Start 00:00:00 00:00 Impedance - Impedance Values 00:00:00 00:00 Change - Montage Apply: 0bical.mtg 00:00:17 00:00 Calibration Off 00:00:18 00:00 Change - Montage Apply: 1doublebanana.mtg 00:00:36 00:00...
doesn't really allow me to determine what you call "text", or columns 1, 2, 3. Could you be more specific or reformat the question using "code" formatting?
There are several options for extracting data from a text file, ranging from TEXTREAD/SCAN, STRFIND, etc, for formatted enough content, to regular expressions for pattern matching in more complicated or less formatted content. Once you refine the question, we can talk about an appropriate approach.
Risposta accettata
Più risposte (3)
2 Commenti
Matt Kindig
il 25 Apr 2013
Modificato: Matt Kindig
il 25 Apr 2013
Can you also post your intended output, i.e., what data after the 8th line that you want to retain, how you want to be structured, etc.? Your goal is still a bit unclear.
Cedric
il 25 Apr 2013
After the 8th line, you have multiple blocks of
Exam Start 00:00:00 00:00
Impedance - Impedance Values 00:00:00 00:00
Change - Montage Apply: 0bical.mtg 00:00:23 00:00
Calibration Off 00:00:26 00:00
that you want to transpose into a structure that has one row per block?
D. Ali
il 27 Apr 2019
0 voti
I have similar question where I need to extarct all MCAP with time they occured on in separat file and plot if possilbe
I attached the file
Categorie
Scopri di più su Text Files 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!