Exemple #1
0
        void appentToRichTextBox(string fileName)
        {
            // Read sample data from CSV file
            richTextBox1.Clear();
            using (CsvFileReader reader = new CsvFileReader(txtOutputPath.Text + @"\" + fileName))
            {
                CsvRow row     = new CsvRow();
                int    counter = 0;

                while (reader.ReadRow(row))
                {
                    if (counter == 0 || row.Contains("$"))
                    {
                        counter++;
                        continue;
                    }

                    foreach (string s in row)
                    {
                        richTextBox1.AppendText(s);
                        richTextBox1.AppendText("\t");
                    }
                    richTextBox1.AppendText("\n");;
                    counter++;
                }
            }
        }
Exemple #2
0
        public void ProcessCsvFile(string filePath, string outputPath, string roundNo)
        {
            if (String.IsNullOrEmpty(filePath))
            {
                throw new Exception("The file path for " + roundNo + " round results must be provided!");
            }
            if (String.IsNullOrEmpty(outputPath))
            {
                throw new Exception("The output path must be provided!");
            }

            //results
            List <CsvRow> results = new List <CsvRow>();

            // Read sample data from CSV file
            using (CsvFileReader reader = new CsvFileReader(filePath))
            {
                CsvRow row     = new CsvRow();
                int    counter = 0;

                // Write sample data to CSV file
                string file = outputPath + @"\" + roundNo + "RoundResults_final.csv";

                if (!File.Exists(file))
                {
                    using (CsvFileWriter writer = new CsvFileWriter(file))
                    {
                        while (reader.ReadRow(row))
                        {
                            if (counter == 0 || row.Contains("$"))
                            {
                                counter++;
                                continue;
                            }
                            if (counter == 1)
                            {
                                row.Clear();
                                string heading = roundNo + " Round Results";
                                row.Add(heading);
                                row.LineText = heading;
                            }

                            writer.WriteRow(row);
                            counter++;
                        }
                    }
                }
                else
                {
                    throw new Exception("The file " + roundNo + "RoundResults_final.csv already exists! Please remove it if you need to regenerate the CSV file.");
                }
            }
        }