So the problem is: I have a file with *.sld extesnion. This file contains about 94 columns and 24500 rows with numbers and can be read by as normal text file. What is the best way to access these numbers from program? For example, I want all numbers from column 15 to be stored as double. What options do I have? I have tried dataTable, but loading whole file with File.ReadAllLines takes about 150MB of RAM memory to run the program and I have to consider that more than one file like this will be used by the program. The piece of *.sld file looks like this:
0.000 96.47 2.51 1.43 2.56 2.47 5.83 -> more columns
1.030 96.47 2.52 1.39 3.14 2.43 5.60 |
2.044 96.47 2.43 1.63 2.96 2.34 5.86 \/
3.058 96.47 2.47 0.76 2.59 2.44 5.62 more rows
4.072 96.47 2.56 1.39 2.99 2.38 5.89
Except there are more columns and rows mentioned before. My solution was something like this:
//Read all lines of opened file to string array
string[] lines = System.IO.File.ReadAllLines(@OFD.FileName,Encoding.Default);
//Remove more than one whitespace with only one whitespace in cycle (cycle not shown)
string partialLine = Regex.Replace(lines[i], @"\s+", " ");
//Split string to string array and add it to dataTable
string[] partialLineElement = partialLine.Split(new char[]{' '}, StringSplitOptions.RemoveEmptyEntries);
fileData.Rows.Add(partialLineElement);
But I have problems accessing whole column of data and it´s a string array, not double numbers. I need it to add one column of this file to ZedGraph as double[]. I have also tried assign this dataTable to dataGridView as:
dataGridView1.DataSource = fileData;
dataGridView1.Refresh();
But how to access columns as double[] ??? Any suggestions ?