public static CsvDataStructure ReturnClassObject(string wordCount) { CsvDataStructure obj = new CsvDataStructure { WordCount = wordCount }; return(obj); }
public void TestAppendDateInListIfNotInList() { CsvDataStructure csvData = csvData = new CsvDataStructure(); CsvDataManipulator.AppendDateInListIfNotInList("04/02/2020", csvData); CsvDataManipulator.AppendDateInListIfNotInList("07/02/2020", csvData); CsvDataManipulator.AppendDateInListIfNotInList("09/02/2020", csvData); Assert.NotNull(csvData.Date); }
public static Dictionary <string, CsvDataStructure> ReadInDicFromCsv(string filePath) { Dictionary <string, CsvDataStructure> fileContent = new Dictionary <string, CsvDataStructure>(); var sr = new StreamReader(filePath); string line; while ((line = sr.ReadLine()) != null) { var words = line.Split(','); try { CsvDataStructure obj = ReturnClassObject(words[1]); fileContent.Add(words[0], obj); } catch (System.Exception) { WriteLine("Error while reading the file"); } } sr.Close(); return(fileContent); }