How do I extract data from a .dat file contain multiple tables?
Show older comments
The example of .dat file is this one . There are various tables for varying RPM of the propellers. I want to be able to extract all the data such that I can make various plots from the data for each RPM.
A direct importdata('PER3_5X5E.dat') puts all the data in one single cell without distributing the data in any manner. This was also the case when I removed all the header text from the .dat file and the file started directly with the RPM value.
Accepted Answer
More Answers (1)
dpb
on 11 Jun 2017
1 vote
Read the full file into character array and then search for the RPM line; that will give you a set of sections within which to interpret the numeric values into cell arrays by RPM.
Did the importdata solution save the RPM values in a cell? If so, looks like you should be able to just find the V==0.0 data to locate the sections similarly as to the text search above and reformat the big cell array into smaller ones. If the RPM data were lost entirely, then you'd need to reconstruct that of course.
Alternatively, just start a loop and fgetl a line at a time and parse it -- throw away what you get until RPM, read it, you then know how many lines to skip to read a section and "rinse and repeat" until feof
Categories
Find more on Tables in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!