public void CanParseCSVDataWithEmbeddedLineBreaks() { var map = CSVColumnMapping.CreateFromType <SomeOtherData>(); string testPath = Path.Combine(TestFolder, "EmbeddedBreaks.csv"); CSVFile f = new CSVFile(testPath); var line = f.Lines[0]; Assert.AreEqual(3, line.Values.Count, "There should only be three values for this line!"); Assert.AreEqual("123", line[0]); string expectedContent = "My Data" + Environment.NewLine + "looks great \"in quotes!\", so let's" + Environment.NewLine + "see what we can do with it"; Assert.AreEqual(expectedContent, line[1], "Invalid value for 'Content'!"); Assert.AreEqual("3.14159", line[2]); }
/// <summary> /// Create a list of column mappings from a list of strings. /// </summary> private List <CSVColumnMapping> CreateColumnMappings(string[] colNames) { var res = new List <CSVColumnMapping>(); int index = 0; foreach (var name in colNames) { var map = new CSVColumnMapping() { Index = index, Name = name }; res.Add(map); ++index; } return(res); }