public static void Run(string inputFile, string outputFile = null, string fileType = null) { List <string[]> data = CsvTools.ReadStudentsGroup(inputFile); Group group = new Group(data); Console.WriteLine(group); if (fileType != null && outputFile != null) { if (fileType.ToUpper() == "JSON") { JsonTools.SaveStudentsGroup(group, outputFile); Console.WriteLine("Записано в JSON."); } else if (fileType.ToUpper() == "XLSX") { ExcelTools.SaveStudentsGroup(group, outputFile); Console.WriteLine("Записано в XLSX."); } } }
static void Main(string[] args) { try { if (args[0] == "-i" && args[2] == "-o" && args[4] == "-f") { var data = CsvReaderTools.Read(args[1]); Group group = new Group() { Students = data }; group.CalcAvg(); if (args[5] == "JSON") { JsonTools.Write(group, args[3] + ".json"); } if (args[5] == "EXCEL") { ExcelTools.Write(group, args[3] + ".xlsm"); } } else { throw new Exception("bad params"); } //var data = CsvReaderTools.Read("data.csv"); //Group group = new Group() { Students = data }; //group.CalcAvg(); //JsonTools.Write(group, "1.json"); //ExcelTools.Write(group, "Base.xlsx"); } catch (Exception ex) { WriteLine(ex.Message); } WriteLine("Работа закончена"); }