예제 #1
0
        public static string[] GetColumns(string filePath)
        {
            if (!PathChecker.DoesPathExists(filePath))
            {
                throw new Exception("File doesn't Exist");
            }

            var sr = File.OpenText(filePath);

            string[] columns   = null;
            var      firstLine = sr.ReadLine();

            if (!string.IsNullOrEmpty(firstLine))
            {
                columns = firstLine.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            }
            return(columns);
        }
예제 #2
0
        static void Main(string[] args)
        {
            var path = @"D:\a\ReviewOfReviews-S21B1\ReviewOfReviews-S21B1\Sample1.csv";

            if (!PathChecker.DoesPathExists(path))
            {
                Console.WriteLine("Provide a Existing path");
                System.Environment.Exit(1);
            }

            ICsvFileReader fileReader = new CsvFileReader();

            string[] rows = fileReader.Read(path, new string[] { "ReviewDate", "Comments" });
            rows = fileReader.SkipHeader(rows);
            IConsoleWriter consoleWriter = new ConsoleWriter();

            consoleWriter.Write(rows, 0, 1);
        }
예제 #3
0
        static void Main()
        {
            var path = @"D:\a\review-case-s21b1\review-case-s21b11\Sample1.csv";

            //var path = "C:/Users/Ajay kumar/Desktop/Sample2.csv";
            if (!PathChecker.DoesPathExists(path))
            {
                Console.WriteLine("Provide a Existing path");
                System.Environment.Exit(1);
            }
            if (!CheckCsvFormat.CheckFormat(path, new string[] { "ReviewDate", "Comments" }))
            {
                Console.WriteLine("File is not in required format");
                System.Environment.Exit(1);
            }
            ICsvFileReader fileReader = new CsvFileReader();

            string[] rows = fileReader.Read(path, new string[] { "ReviewDate", "Comments" });
            rows = fileReader.SkipHeader(rows);
            IConsoleWriter consoleWriter = new ConsoleWriter();

            string[] dataToPrintOnConsole = consoleWriter.GetDataInWritableFormat(rows, 0, 1);
            consoleWriter.WriteToConsole(dataToPrintOnConsole);
        }