Pull numeric data from a mixed text file
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi, I have a >15,000 row mixed data (numbers and strings). I want to pull some of the data from different parts of the text file. In the attached file I shortend the file shows only some of the lines I am interstsed. (There are thousonds of rows above these lines and lines between them as well).
- My first question is tabout the file extension of .o. How would I read this file (with extension of .o) without changing to . txt. The attached file has txt extension for the sake of this site but actually it is .o
- In the attached file I would like to pull some of the numeric values. How would I pull these numeric valuses when they are burried in the string rows?
Here is the numeric data I want to pull out from the test file in the attachment.
1.18, 0.00002,
7.9256-04 1.13 and the table values from
"gen time", "rossi-a", "b-eff" (both the estimate and the std val).
I am not intersted pull the string but the valuse in this problem.
3. I tried using readtable but I am not sure that is the right code to use. Any recommendations? I have about 220 files and I am going to pull the data for 220 files using a for loop. The values changes in each file.
Thank you
0 Commenti
Risposte (1)
Saffan
il 7 Set 2023
Hi Birsen,
To read a file with “.o” extension, you can use the “fileread” method as follows:
fileContent = fileread(filename);
To extract numeric data from a specific part of the file, you can identify the start and end indices of the section containing the desired data. In the provided file, the text "the final estimated combined collision" consistently appears, and the desired section is located after this text. Therefore, we can use it as a reference point. Here's an example:
startIndex = strfind(fileContent, 'the final estimated combined collision');
desiredFileContent = fileContent(startIndex :end);
Numeric values can then be extracted from the desired section using regular expressions and stored in appropriate data structures.
Please refer to this for more information:
0 Commenti
Vedere anche
Categorie
Scopri di più su Data Import and Export 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!