|
On 13 Jul, 16:55, "Arthur Zheng" <hzhe...@gatech.edu> wrote:
> how to read the whole file into a single string including the whitespace and newline?
>
> The file looks like :
> AAur_0001 dnaA 1 1..1419 1419
> AAur_0002 dnaN 1995 1995..3119 1125
> AAur_0003 3224 3224..4108 885
> AAur_0004 recF 4132 4132..5331 1200
>
> Note I want the result in a single string, not several strings. Can I use textread or any other function? thanks.
Bad idea. If the file is small, you will not gain any
significant speed by doing this. If the file is large,
you might gain speed but end up in 'Out of Memory' type
problems. The best strategy is to use a file buffer
of moderate size (say, 10 MBytes), and read the file
in chunks. I have no idea of how to do this in matlab,
though.
If the file is large and speed is a concern, you might
want to port to C or C++. The newest C++ standard (I don't
know about C) has support for regular expressions included,
so you will be able to use the stuff you already have with
only minor modifications. Both C and C++ allows some
manipulation of I/O buffer sizes, so you can gain a bit of
speed while keeping memory usage under control.
Rune
|