public void DataWithMultiDelimiter2() { const string CSV_CONTENT = @"test,@d,@,""d,@,ata"",@,123"; var filePath = GetUniqueFilePath(); ManageTempFile(filePath, CSV_CONTENT, () => { var reader = new System.IO.CsvReader(delimiter: ",@,"); var result = reader.Parse(filePath).ToList(); Assert.AreEqual(1, result.Count); Assert.AreEqual("test,@d", result[0][0]); Assert.AreEqual("d,@,ata", result[0][1]); Assert.AreEqual("123", result[0][2]); }); }
public void NormalTextDataEnd() { const string CSV_CONTENT = @"test,""data"",""123"""; var filePath = GetUniqueFilePath(); ManageTempFile(filePath, CSV_CONTENT, () => { var reader = new System.IO.CsvReader(); var result = reader.Parse(filePath).ToList(); Assert.AreEqual(1, result.Count); Assert.AreEqual("test", result[0][0]); Assert.AreEqual("data", result[0][1]); Assert.AreEqual("123", result[0][2]); }); }
public void TextDataWithMultiTextQualifier() { const string CSV_CONTENT = "test,\"@d\"@\"@ata\"@,123"; var filePath = GetUniqueFilePath(); ManageTempFile(filePath, CSV_CONTENT, () => { var reader = new System.IO.CsvReader(textQualifier: "\"@"); var result = reader.Parse(filePath).ToList(); Assert.AreEqual(1, result.Count); Assert.AreEqual("test", result[0][0]); Assert.AreEqual("d\"@ata", result[0][1]); Assert.AreEqual("123", result[0][2]); }); }
public void DataEndCustomEndOfRowMarker() { const string CSV_CONTENT = @"test,""data"",123|row2"; var filePath = GetUniqueFilePath(); ManageTempFile(filePath, CSV_CONTENT, () => { var reader = new System.IO.CsvReader(endOfRowMarker: "|"); var result = reader.Parse(filePath).ToList(); Assert.AreEqual(2, result.Count); Assert.AreEqual("test", result[0][0]); Assert.AreEqual("data", result[0][1]); Assert.AreEqual("123", result[0][2]); Assert.AreEqual("row2", result[1][0]); }); }
public void StartAt3Line() { const string CSV_CONTENT = @" col1,col2 r1col1,r1col2"; var filePath = GetUniqueFilePath(); ManageTempFile(filePath, CSV_CONTENT, () => { var reader = new System.IO.CsvReader(startAtLine: 2); var result = reader.Parse(filePath).ToList(); Assert.AreEqual(2, result.Count); Assert.AreEqual("col1", result[0][0]); Assert.AreEqual("col2", result[0][1]); Assert.AreEqual("r1col1", result[1][0]); Assert.AreEqual("r1col2", result[1][1]); }); }