I need help in reading the attributes in the attached text file. I am taking values from 8 textboxes as inputs and i then want to compare those textbox values with the attributes in the text file and then want to generate decision based on them. 0 and 1 represent decision.
I need help in reading the attributes in the attached text file. I am taking values from 8 textboxes as inputs and i then want to compare those textbox values with the attributes in the text file and then want to generate decision based on them. 0 and 1 represent decision.
Kindly find the attached file
Sorry wrong file attached. here is the correct file.
What exactly do you mean by "Attributes" ?
Taking a guess, you need to:
Code:
string[] lines = File.ReadAllLines(filePath);
foreach (string line in lines)
{
string[] splitLine = line.Split(':');
// followed by more splitting etc
// to get each
// attribute (glucose_tol)
// operator (<=)
// operand (127)
// result (0)
// make a class/struct out of the above
}
I think you then need to build some sort of (decision) Tree structure, where each node is a class/struct from above, with glucose_tol at the root....
You should then be able to write a routine to take values for attributes and process them, through your decision tree to obtain a diagnosis (result).
I recommend you use a regular expression for the parsing of this file. It's fast and gives you good control.
Here is some code that will parse your file and pull out the relevant parts. I'm not sure what you mean by attributes so I pull out any of the useful stuff and leave it to you to choose what you want:
Code:
using System;
using System.IO;
using System.Text.RegularExpressions;
namespace RedBully
{
class Program
{
/// <summary>
/// Regular expression for parsing OutSave.txt
/// </summary>
private const string REG_EX = @"^\s*(\w+)\s([<=>]{1,2})\s([\d\.]+).\s\:\s([01])\s*$";
static void Main(string[] args)
{
//Read in the file
StreamReader sr = File.OpenText("outSave.txt");
string data = sr.ReadToEnd();
//Create Regular Expression to parse the data
Regex regEx = new Regex(REG_EX, RegexOptions.Multiline);
//Find each match on each line
Match match = regEx.Match(data);
do
{
//Output the different parts of each line to console.
//***You can access the data you need using the groups and use them as you like
Console.WriteLine("Attribute: " + match.Groups[1].ToString());
Console.WriteLine("Operator: " + match.Groups[2].ToString());
Console.WriteLine("Value: " + match.Groups[3].ToString());
Console.WriteLine("0 or 1: " + match.Groups[4].ToString());
Console.WriteLine("-----");
match = match.NextMatch();
}
while (match.Success);
//Puase before end of program
Console.WriteLine("Press a key to continue...");
Console.ReadKey();
}
}
}
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.