Exemple #1
0
 //This will parse the data to a Data Set
 public void parseFileToDataSet(String filePath, data textDatabase)
 {
     //This function is a test function to parse items into a dataset.
     String[] FileLines = System.IO.File.ReadAllLines(filePath); // This will store all the lines of the file into a string array
     foreach (String line in FileLines)
     {
         int tabCount = 0; // reset the tabCount
         String[] temp = new String[tabCount];
         foreach (char c in line)
         {
             if (c.Equals('\t'))
             {
                 tabCount++;
             }
         }
         if (tabCount > 0)  // if the line contains tab characters, it means that it is a data line. So it should be parsed and added to our data structure.
         {
             // here we will resize the array depending on the tabCount
             temp = (String[])resizeArray(temp, tabCount + 1);
             temp = line.Split('\t');
             if ( temp[0].Equals("Day") || temp[0].StartsWith("The") || temp[0].Equals("") )  // this won't add the first row which contains the headings.
                 /*do nothing*/;
             else
                 textDatabase.addRow(temp, textDatabase);  // This will add the parsed data as a row in the database.
         }
     }
 }
Exemple #2
0
 public Viewer(data database)
 {
     InitializeComponent();
     TextDataGrid.DataSource = database.getDataTable();
     assignDatabaseToViewer(database.getDataTable());
     undoTable = createUndoTable();
     undoTypeTable = createUndoTypeTable();
     undoTypeTableView.DataSource = undoTable;
     undoTableView.DataSource = undoTypeTable;
 }
Exemple #3
0
 public static void Main()
 {
     //Let us first create an instance of the database
     data textDatabase = new data();
     //Let us also create an instance of the parser class
     Parser textParser = new Parser();
     //Let us also get the filePath that we're going to use. For now, it is going to be hard-coded
     String filePath = Application.StartupPath.ToString() + @"\tripResult_m.txt";
     // This will be the main store for the data that we collect from the text file
     //Now we shall add the parased data to this database.
     textParser.parseFileToDataSet(filePath, textDatabase);
     //Now once we have parsed the database. We need to view it in our DataGridView.
     //For that we will first create an instance of the Viewer
     Application.Run(new Viewer(textDatabase));
     DateTime currentDateTime = DateTime.Now;
     String tempDateTime = currentDateTime.ToString("yyMMdd_HHmmss");
     //String newFilePath = @"C:\Users\Abhishek Datar\Documents\Visual Studio 2010\Projects\Text Parser\Text Parser\tripResult_m_" + tempDateTime + ".txt";
     String newFilePath = Application.StartupPath.ToString() + @"\tripResult_m_" + tempDateTime + ".txt";
     String newFileText = textParser.buildStringForWriting(textDatabase);
     System.IO.StreamWriter file = new System.IO.StreamWriter(newFilePath);
     file.WriteLine(newFileText);
     file.Close();
 }
Exemple #4
0
 public void addRow(String[] line, data textDatabase)
 {
     DataTable table;
     table = textDatabase.getDataTable();
     table.Rows.Add(line[0], line[1], line[2], line[3], line[4], line[5], line[6], line[7], line[8], line[9], line[10], line[11], line[12], line[13], line[14], line[15]);
 }