Procedure too slow

Hi!

I've programmed a function that rads a .csv and saves its values in an array. The csv looks like that "0,0,0,0,0,1,1,0,0,0,0,1,1,"

But somehow it's so slow, it takes about one minute for 500 numbers (and i have millions) That's how I've done it:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
	while( getline(inT,lineT) )
	{
		LINE lnT;
		while( (posT = lineT.find(',')) >= 0)
		{
			string fieldT = lineT.substr(0,posT);

			lineT = lineT.substr(posT+1);
			
			if(xCoord >=sizeX) //Füllen des Arrays
			{
				xCoord = 0;
				yCoord++;
			}
			TTCworldCoord[xCoord][yCoord] = strtod(fieldT.c_str(), NULL);
			xCoord++;

		}

	}


Is there a faster way?
What type is TTCworldCoord? If it's not a 2d array, you could improve performace by filling one dimension at a time. BTW, do you really mean to read millions of rows into memory?

Forget all the std::string stuff. Read the line into a char array, and use strtok to parse fields.
Thanks! TTCworldCoord is of type double[][]. Are the strtok methods much faster?
Topic archived. No new replies allowed.