Hello
I'm currently having a few problems with trying to read some data into an array and then workout the averages of all the data.
I can read in all the data into an array line by line, the problem is I need to work out the averages of the all of the bits of data in individual columns.
For example the data is stored like this in a text file.
[HRData]
97 117 0 -117 0 50
97 117 0 -117 0 50
97 183 0 -117 0 50
94 183 55 -117 34 50
95 210 56 -117 84 4931
95 207 59 -117 113 5438
95 196 57 -117 125 5944
97 248 56 -117 125 5944
98 255 64 -117 141 5432
100 252 64 -117 141 5432
101 248 79 -117 147 5444
102 237 82 -117 146 6456
104 235 82 -117 142 6457
105 247 84 -117 134 6458
106 261 87 -117 146 7220
106 268 87 -117 146 7220
107 281 91 -117 152 7475
108 292 95 -117 161 7733
109 297 98 -117 173 8245
110 301 101 -117 179 7733
111 299 103 -117 186 6966
112 297 106 -117 193 6445
113 294 105 -117 200 6706
115 293 104 -117 190 6703
116 294 103 -117 191 5685
117 297 105 -117 193 5688
118 294 105 -117 193 5432
118 293 103 -117 206 4922
119 293 103 -117 207 4914
120 294 104 -117 201 5678
120 294 104 -117 211 6195
121 292 103 -117 192 5939
121 289 102 -117 198 6712
122 291 102 -117 191 6201
122 288 102 -117 197 6459
123 286 101 -117 198 7478
I want to get the average of all the bits of data from the first column and then the second and so on.
This is the code I'm using to read in the data.
private List<string> GetDataFromFile()
{
List<string> list = new List<string>();
string tag = "[HRData]";
bool bGetText = false;
string path = (Chosen_File);
using (StreamReader sr = new StreamReader(path))
{
string line;
while ((line = sr.ReadLine()) != null)
{
if (bGetText)
list.Add(line);
else if (line == tag)
bGetText = true;
}
}
return list;
}
Any help would be great, thank you.