Hello

I have a txt file with multiple values in six different columns.
What I need to do is get each column of data and place them into individual arrays for later use. Also once I have the data I need to convert the arrays into integers.

This is the contents of the txt 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

I have currently been trying to catch each line of data into individual arrays and then split them up but I've failed dramatically.

Any help would be greatly appreciated.

Thank you.

this is not the best practice but it gets the job done if you need it fast.

ArrayList ar1 = new ArrayList();
ArrayList ar2 = new ArrayList();
ArrayList ar3 = new ArrayList();
ArrayList ar4 = new ArrayList();
ArrayList ar5 = new ArrayList();
ArrayList ar6 = new ArrayList();
string filePath = "file.txt";
StreamReader sr = new StreamReader(filePath);
while (sr.ReadLine() != null)
{
    string[] line = sr.ReadLine().Split("\t".ToCharArray());
    for(int i = 0; i < line.Length; i++)
    {
        ar1.Add(line[i]);
        ar2.Add(line[i + 1]);
        ar3.Add(line[i + 2]);
        ar4.Add(line[i + 3]);
        ar5.Add(line[i + 4]);
        break;
    }
 }
sr.Close();

This assumes you know the number of columns in the text file. If you later need to use the values from the array as integers just use Convert.ToInt32(ar1[0]) and so on.

This question has already been answered. Start a new discussion instead.