I tried the solution Alan kindly provided to me( find the question and reply, below) , but every time there is an error say , the argument is not in correct format...
would you please tell me about?To simplify my question, please look at below simplified example, ( you can find the previous question and codes, below section)
you can think of the 16 data like this:I would like to put them in a 3d array with 4*2*2 dimension.
data file:1 2 3 4 5 6 7 89 10 11 12 1314 15 16 so,for k=0 I have ,1 2 3 45 6 7 8and for k=1 I have9 10 11 1213 14 15 16for example A[0,0,0]=1A[1,0,0]=2A[2,0,0]=3A[3,0,0]=4A[0,1,0]=5A[1,1,0]=6A[2,1,0]=7A[3,1,0]=8A[0,0,1]=9A[1,0,1]=10A[2,0,1]=11A[3,0,1]=12A[0,1,1]=13A[1,1,1]=14A[2,1,1]=15A[3,1,1]=16
--PREVIOUS Question-----------------------------------------------------------------------------------------------------------------------------------------
I have a text data file including Double type data , as below;x x x xx x x x...x x
How to read this data file line-by line from left to right and put them in a 3D array(in C#). The order of numbers in data file is in the way that first i changes from 0-75, then j to 139 and then k to149.it means the filling procedure is like this
reading to array from (0,0,0) to (75,0,0) then (0,1,0) to (75,1,0)... then(0,139,0)to(75,139,0)(0,0,1) to(75,0,1) then(0,1,1)to(75,1,1)... then(0,139,1)to(75,139,1)...(0,0,149)to(75,0,149) then (0,1,149)to(75,1,149) ...then(0,139,149)to(75,139,149)
------Previous solution( cause error)-----------------------------------------------------------------------------------------------------------------------------------------------------
double[,,] dArray = new double[76,140,150];string line = null;string[] numbers = null;
StringReader sr = new StringReader(filePath);
for (int k = 0; k < 149; k++){ for(int j = 0; j < 139; j++) { line = sr.ReadLine(); numbers = line.Split(','); for(int i = 0; i < 75; i++) { dArray[i,j,k] = double.Parse(numbers[i]); } }}
sr.Close();