Ok, let me give you a 'possible' solution:
1-If there are a lot of, and not well-know, of possible values to save, don't use a matrix. I'd rather use a DataTable. It allows to add a lot of data and get ordered values later.
I write some textfile corresponding to your structure, in fact, assuming this is the correct format.
Before to use your own text file be sure it match the correct schema.
Suj01_PI_DP_C00_1
Date:,2014/11/06
Time:,14:55:12
Type:,test
Description:,""
Notes:,""
TRAJECTORIES
100.000000,Hz
,Suj01:RIAS,,,Suj01:LIAS,,,Suj01:LIPS
Field #,X,Y,Z,X,Y,Z,X,Y,Z,X,Y,Z,X
1,-242.807816,1106.551270,1097.119385,14.437944,1075.778687,1097.119385,14.437944,1075.778687
100.000000,Hz
,Suj01:RIAS,,,Suj01:RIPS,,,Suj01:LIPS
Field #,X,Y,Z,X,Y,Z,X,Y,Z,X,Y,Z,X
3,-242.807816,1106.551270,1097.119385,14.437944,1075.778687,1097.119385,14.437944,1075.778687
100.000000,Hz
,Suj01:RIAS,,,Suj01:DSTR,,,Suj01:C7
Field #,X,Y,Z,X,Y,Z,X,Y,Z,X,Y,Z,X
1,-242.807816,1106.551270,1097.119385,14.437944,1075.778687,1097.119385,14.437944,1075.778687
100.000000,Hz
,Suj01:LIAS,,,Suj01:LIPS,,,Suj01:C7
Field #,X,Y,Z,X,Y,Z,X,Y,Z,X,Y,Z,X
5,-242.807816,1106.551270,1097.119385,14.437944,1075.778687,1097.119385,14.437944,1075.778687
And this is the code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace test1
{
class Program
{
static int Main(string[] args)
{
System.Data.DataTable tdata = new System.Data.DataTable();
tdata.Columns.Add("Name", typeof(string));
tdata.Columns.Add("X", typeof(double));
tdata.Columns.Add("Y", typeof(double));
tdata.Columns.Add("Z", typeof(double));
System.IO.StreamReader reader = new System.IO.StreamReader(@"..\..\TextFile1.txt");
string line = "", captions = "", values = "";
bool wrong_header = false;
using ( reader )
{
for (int x = 0; x < 8; x++)
{
if ((line = reader.ReadLine()) == null)
{
wrong_header = true;
break;
}
}
if (wrong_header)
{
return -1;
}
while (true)
{
if ((line = reader.ReadLine()) == null) break;
if ((captions = reader.ReadLine()) == null) break;
if ((line = reader.ReadLine()) == null) break;
if ((values = reader.ReadLine()) == null) break;
string[] scap = captions.Split(new string [] {",,,"}
, StringSplitOptions.RemoveEmptyEntries);
string[] sval = values.Split(new char [] {','});
int pos_value = 0;
foreach(string caption in scap)
{
System.Data.DataRow row = tdata.NewRow();
row["Name"] = caption.Substring(1, caption.Length - 1);
row["X"] = Convert.ToDouble(sval[pos_value++]);
row["Y"] = Convert.ToDouble(sval[pos_value++]);
row["Z"] = Convert.ToDouble(sval[pos_value++]);
tdata.Rows.Add(row);
}
}
}
Console.WriteLine("Ordered by name");
System.Data.DataRow[] v_order_by_name = tdata.Select("", "Name");
foreach(System.Data.DataRow rsort in v_order_by_name)
{
string msg = string.Format("{0}: {1},{2},{3}", rsort[0],rsort[1],rsort[2],rsort[3]);
Console.WriteLine(msg);
}
Console.WriteLine();
Console.WriteLine();
Console.WriteLine("Filtered by name RIAS");
System.Data.DataRow[] v_filtered_by_name = tdata.Select("Name = 'Suj01:RIAS'", "");
foreach (System.Data.DataRow rfilter in v_filtered_by_name)
{
string msg = string.Format("{0}: {1},{2},{3}", rfilter[0], rfilter[1], rfilter[2], rfilter[3]);
Console.WriteLine(msg);
}
Console.WriteLine("Press any key.");
Console.ReadKey();
return 0;
}
}
}
And this is the result:
Ordered by name
Suj01:LIAS: 5,-242.807816,1106.55127
Suj01:RIAS: 1,-242.807816,1106.55127
Suj01:RIAS: 3,-242.807816,1106.55127
Suj01:RIAS: 1,-242.807816,1106.55127
uj01:C7: 1097.119385,14.437944,1075.778687
uj01:C7: 1097.119385,14.437944,1075.778687
uj01:DSTR: 1097.119385,14.437944,1075.778687
uj01:LIAS: 1097.119385,14.437944,1075.778687
uj01:LIPS: 1097.119385,14.437944,1075.778687
uj01:LIPS: 1097.119385,14.437944,1075.778687
uj01:LIPS: 1097.119385,14.437944,1075.778687
uj01:RIPS: 1097.119385,14.437944,1075.778687
Filtered by name RIAS
Suj01:RIAS: 1,-242.807816,1106.55127
Suj01:RIAS: 3,-242.807816,1106.55127
Suj01:RIAS: 1,-242.807816,1106.55127
Press any key.
I hope it helps you.
Salut