本文整理汇总了C#中CsvReader.SkipRecord方法的典型用法代码示例。如果您正苦于以下问题:C# CsvReader.SkipRecord方法的具体用法?C# CsvReader.SkipRecord怎么用?C# CsvReader.SkipRecord使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CsvReader
的用法示例。
在下文中一共展示了CsvReader.SkipRecord方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: skip_plain_csv
public void skip_plain_csv(WhiteSpacePreservation whiteSpacePreservation)
{
var repeatCount = 100000;
using (var textReader = new EnumerableStringReader(Data.PlainDataLines.Repeat(repeatCount)))
using (var csvReader = new CsvReader(textReader))
{
csvReader.PreserveLeadingWhiteSpace = whiteSpacePreservation.HasFlag(WhiteSpacePreservation.Leading);
csvReader.PreserveTrailingWhiteSpace = whiteSpacePreservation.HasFlag(WhiteSpacePreservation.Trailing);
while (csvReader.HasMoreRecords)
{
csvReader.SkipRecord();
}
Assert.Equal(3 * repeatCount, csvReader.RecordNumber);
}
}
示例2: skip_csv_with_copious_escaped_delimiters
public void skip_csv_with_copious_escaped_delimiters(WhiteSpacePreservation whiteSpacePreservation)
{
var repeatCount = 100000;
using (var textReader = new EnumerableStringReader(Data.CopiousEscapedDelimitersLines.Repeat(repeatCount)))
using (var csvReader = new CsvReader(textReader))
{
csvReader.PreserveLeadingWhiteSpace = whiteSpacePreservation.HasFlag(WhiteSpacePreservation.Leading);
csvReader.PreserveTrailingWhiteSpace = whiteSpacePreservation.HasFlag(WhiteSpacePreservation.Trailing);
while (csvReader.HasMoreRecords)
{
csvReader.SkipRecord();
}
Assert.Equal(repeatCount, csvReader.RecordNumber);
}
}
示例3: ReadCSVFromFileWithExplicitHeader
private static void ReadCSVFromFileWithExplicitHeader()
{
#region ReadCSVFromFileWithExplicitHeader
using (var streamReader = new StreamReader("PlanetaryData_NoHeader.csv"))
using (var reader = new CsvReader(streamReader))
{
reader.HeaderRecord = new HeaderRecord("OfficialName", "NickName");
while (reader.HasMoreRecords)
{
var dataRecord = reader.ReadDataRecord();
Console.WriteLine("{0} is nicknamed {1}.", dataRecord["OfficialName"], dataRecord["NickName"]);
reader.SkipRecord();
}
}
#endregion
}