T
toton
Hi,
I have some ascii files, which are having some formatted text. I want
to read some section only from the total file.
For that what I am doing is indexing the sections (denoted by .START
in the file) with the location.
And for a particular section I parse only that section.
The file is something like,
.... DATAS
.....
..START
....
.....
..START
....
......
etc.
I need to parse datas between two .START when only that section is
needed. I don't load all of the data's in the memory at a time, as the
file is big, 4MB~20MB in size.
To mark all of the .START I parse it once, just to check .START and
mark that position, and when actually the detailed data is needed seek
to that marked position and do parsing.
For quick parsing, I do
while(_stream) {
std::string currentLine;
getline(_stream, currentLine);
currentLine = utils::trim(currentLine);///this removes whitespace
from front & back.
if (currentLine == ".START"){
_pos.push_back(_stream.tellg());
}
}
But this code runs slower than I expect. Anything better can be done
here ? like some buffering in the stream etc? .
abir
I have some ascii files, which are having some formatted text. I want
to read some section only from the total file.
For that what I am doing is indexing the sections (denoted by .START
in the file) with the location.
And for a particular section I parse only that section.
The file is something like,
.... DATAS
.....
..START
....
.....
..START
....
......
etc.
I need to parse datas between two .START when only that section is
needed. I don't load all of the data's in the memory at a time, as the
file is big, 4MB~20MB in size.
To mark all of the .START I parse it once, just to check .START and
mark that position, and when actually the detailed data is needed seek
to that marked position and do parsing.
For quick parsing, I do
while(_stream) {
std::string currentLine;
getline(_stream, currentLine);
currentLine = utils::trim(currentLine);///this removes whitespace
from front & back.
if (currentLine == ".START"){
_pos.push_back(_stream.tellg());
}
}
But this code runs slower than I expect. Anything better can be done
here ? like some buffering in the stream etc? .
abir