how can I extract the data fast?

1 次查看(过去 30 天)
Pengju
Pengju 2015-9-3
I got one .dat or .txt or .xlsx file with complicated header, and i only need the data at every maybe 15th line.
Could you give a favor to extract the data out, then I can histc them.
Many thanks......

回答(1 个)

Walter Roberson
Walter Roberson 2015-9-4
There is no standard format for .dat files; .dat is similar to .bin in that any program can use it to mean anything and it is not necessarily the same from one version of a program to another. However, if you were to restrict the .dat to having been created by one particular program, it is possible that that program has chosen to use a well-defined and documented structure for the files that could potentially be researched.
.xslx files are verbose and not really designed for fast reading.
.txt files can also mean different things to different programs. However, .txt files are usually human readable well enough for a programmer to be able to deduce the storage format (something that is tricky with a binary format such as .dat) so it is more likely that there is a reasonable solution for .txt files.
Sometimes the solution is to loop using textscan() with a Headerlines option to skip over the unwanted lines and telling textscan to read one line only (textscan does not have an easy way to skip lines between entries -- though it can be done.)
Sometimes the solution is to use a loop to fscanf() the wanted lines and then loop fgetl() to skip the unwanted lines.
Sometimes the best solution is to use an external tool such as Perl to reduce the data down to just the wanted lines and then to process those in MATLAB.

类别

Help CenterFile Exchange 中查找有关 Large Files and Big Data 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by