Пример #1
0
 private void DXWindow_Loaded(object sender, RoutedEventArgs e)
 {
     AlphaTextEdit.Focus();
 }
        private void DXWindow_Loaded(object sender, RoutedEventArgs e)
        {
            using (
                CsvReader csvReader =
                    new CsvReader(
                        new StreamReader(Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName +
                                         @"\biopsy.csv"), hasHeaders: true))
            {
                while (csvReader.ReadNextRecord())
                {
                    xList1.Add(csvReader[2]);
                    xList2.Add(csvReader[3]);
                    xList3.Add(csvReader[4]);
                    xList4.Add(csvReader[5]);
                    xList5.Add(csvReader[6]);
                    xList6.Add(csvReader[7]);
                    xList7.Add(csvReader[8]);
                    xList8.Add(csvReader[9]);
                    xList9.Add(csvReader[10]);
                }

                DataTable dt = new DataTable();
                dt.Columns.Add("x1");
                dt.Columns.Add("x2");
                dt.Columns.Add("x3");
                dt.Columns.Add("x4");
                dt.Columns.Add("x5");
                dt.Columns.Add("x6");
                dt.Columns.Add("x7");
                dt.Columns.Add("x8");
                dt.Columns.Add("x9");
                for (int i = 0; i < xList1.Count; i++)
                {
                    //var row = dt.NewRow();
                    object[] RowValues = { xList1[i], xList2[i], xList3[i], xList4[i], xList5[i], xList6[i], xList7[i], xList8[i], xList9[i] };

                    /*row["x1"] = xList1[i];
                    *  row["x2"] = xList2[i];
                    *  row["x3"] = xList3[i];
                    *  row["x4"] = xList4[i];
                    *  row["x5"] = xList5[i];
                    *  row["x6"] = xList6[i];
                    *  row["x7"] = xList7[i];
                    *  row["x8"] = xList8[i];
                    *  row["x9"] = xList9[i];*/
                    DataRow dRow;
                    dRow = dt.Rows.Add(RowValues);
                    dt.AcceptChanges();
                }

                DataGrid.DataSource = dt;



                xFeatures = new double[xList1.Count, 9];
                //DataGrid.Columns.Add(new GridColumn { Header = "x1", Binding=new Binding("xList1")});
                for (int i = 0; i < xList1.Count; i++)
                {
                    xFeatures[i, 0] = Convert.ToDouble(xList1[i]);
                }

                for (int i = 0; i < xList1.Count; i++)
                {
                    xFeatures[i, 1] = Convert.ToDouble(xList2[i]);
                }
                for (int i = 0; i < xList1.Count; i++)
                {
                    xFeatures[i, 2] = Convert.ToDouble(xList3[i]);
                }
                for (int i = 0; i < xList1.Count; i++)
                {
                    xFeatures[i, 3] = Convert.ToDouble(xList4[i]);
                }
                for (int i = 0; i < xList1.Count; i++)
                {
                    xFeatures[i, 4] = Convert.ToDouble(xList5[i]);
                }
                for (int i = 0; i < xList1.Count; i++)
                {
                    try
                    {
                        xFeatures[i, 5] = Convert.ToDouble(xList6[i]);
                    }
                    catch (FormatException exception)
                    {
                        xFeatures[i, 5] = 0;
                    }
                }
                for (int i = 0; i < xList1.Count; i++)
                {
                    xFeatures[i, 6] = Convert.ToDouble(xList7[i]);
                }
                for (int i = 0; i < xList1.Count; i++)
                {
                    xFeatures[i, 7] = Convert.ToDouble(xList8[i]);
                }
                for (int i = 0; i < xList1.Count; i++)
                {
                    xFeatures[i, 8] = Convert.ToDouble(xList9[i]);
                }

                for (int i = 0; i < xList1.Count; i++)
                {
                    for (int j = 0; j < xList1.Count; j++)
                    {
                        Console.Write(xFeatures[i, j]);
                    }
                    Console.WriteLine(); 9
                }
            }
            AlphaTextEdit.Focus();
        }