Hello everyone ,
i have a text file that contains data like this :
a1 ;AT1 ;AT2 ,CE1 ,CT3
a2 ;AT1 ;AT1 ;CE1 ;CT3
a3 ,CO1 ;CO1 ;CT2 ,CT3
the file is big but that's an example
what i want to do is run through each line of the file and test these things :
1-if there is 2 or more duplicate with the same special character before the string (replace all the occurence with this character)
2-if there is 2 duplicate with a different special character before each one e.g in a3 ,CO1 and ;CO1 (replace them with t)
i wrote a code to do this , but it's not working as wanted ,
thanks for help
string[] tfile = File.ReadAllLines("test.txt");
for (int rowIndex = 0; rowIndex < tfile.Length; rowIndex++)
{
arr = tfile[rowIndex].Split(' ');
//Console.WriteLine(rowIndex + "\t" + arr[0]);
int test = 0;
string[] reslt = null;
for (int ii = 0; ii < arr.Length; ii++)
{
for (int jj = 0; jj < arr.Length; jj++)
{
if ((arr[ii] == arr[jj]) && (ii != jj))
{
//Console.WriteLine(arr[ii] + "\t" + arr[jj] + "\t" + ii + "\t" + jj);
string toreplace = arr[ii];
//Console.WriteLine(toreplace + test + "\n");
if (arr[jj].Contains("-"))
arr[Array.IndexOf(arr, toreplace)] = "-";
else arr[Array.IndexOf(arr, toreplace)] = "+";
}
}
}
test++;
//Console.WriteLine(confStr.Length);
}
//res = arr.ToString();
// Do something with the current line
//File.WriteAllLines("test.txt", );
for (int oo = 0; oo < arr.Length; oo++)
{
Console.WriteLine(arr.Length);
Console.WriteLine(arr[oo]);
}
Console.Read();