Jerry Fike

Jerry Fike

  • NA
  • 107
  • 0

Text Files -- Extracting Data

Jan 7 2010 2:26 PM
I am working on some code to extract some blocks of text data from rather large files.  In one file, there are 13 blocks of text ranging from around 30,000 to 150,000 bytes.  I was using the simple code below to extract and record the data into one block, but it seems extremely slow (several minutes.)  Since it reads into filebuffer from disk in a couple of seconds, it was surprising to me it takes so long to transfer out the blocks of data, especially considering the start and end positions are already identified.

Is there a better way to do this to gain some speed?

for (int i = 0; i < tgoBlockCount; i++)
            {
                for (int j = tgoBlockStart[i]; j < tgoBlockEnd[i]; j++)
                {
                    tgoBlock += fileBuffer[j];
                }
            }

Answers (1)