本文整理汇总了C#中CsvFileReader.ReadFile方法的典型用法代码示例。如果您正苦于以下问题:C# CsvFileReader.ReadFile方法的具体用法?C# CsvFileReader.ReadFile怎么用?C# CsvFileReader.ReadFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CsvFileReader
的用法示例。
在下文中一共展示了CsvFileReader.ReadFile方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestCsvFileReadUsingSoundex
public void TestCsvFileReadUsingSoundex()
{
var reader = new CsvFileReader();
reader.RecordBuilder = new SinglePropertyRecordBuilder(@"Name");
reader.ValueFactory = new SoundexValueFactory(5);
var dataset = reader.ReadFile(new FileInfo(@"data/ReferenceDataset1.csv"), true, ',');
Assert.AreEqual(1, dataset.Records.Count, @"Record count is wrong!");
foreach (var record in dataset.Records)
{
Assert.AreEqual(1, record.Properties.Count, @"Property count is wrong!");
Assert.AreEqual(@"A4253", record.Properties[@"Name"], @"Soundex code is wrong!");
}
}
示例2: TestWritingCsvRecords
public void TestWritingCsvRecords()
{
var reader = new CsvFileReader();
var dataset = reader.ReadFile(new FileInfo(@"data/ReferenceDataset1.csv"), true, ',');
Assert.AreEqual(1, dataset.Records.Count, @"Record count is wrong!");
var record = Enumerable.First<IReferenceRecord>(dataset.Records);
const string Key = @"Name";
var indexWriter = new IndexFileWriter();
var indexFile = new FileInfo(Path.GetTempFileName());
indexWriter.WriteFile(indexFile, dataset.Records);
var indexReader = new IndexFileReader();
var writtenRecords = indexReader.ReadFile(indexFile);
var writtenRecord = Enumerable.First<IReferenceRecord>(writtenRecords);
Assert.AreEqual(record.Properties.Count, writtenRecord.Properties.Count, @"The number of properties do not match!");
Assert.IsTrue(writtenRecord.Properties.ContainsKey(@"Name"), @"There is no property having a key equal to 'Name'!");
Assert.AreEqual(record.Properties[Key], writtenRecord.Properties[Key], @"The property values do not match!");
}
示例3: TestCsvFileRead
public void TestCsvFileRead()
{
var reader = new CsvFileReader();
var dataset = reader.ReadFile(new FileInfo(@"data/ReferenceDataset1.csv"), true, ',');
Assert.AreEqual(1, dataset.Records.Count, @"Record count is wrong!");
}