当前位置: 首页>>代码示例>>C#>>正文


C# CsvFileReader.ReadFile方法代码示例

本文整理汇总了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!");
     }
 }
开发者ID:gisfromscratch,项目名称:geocoding-samples,代码行数:13,代码来源:CsvFileReaderTestSuite.cs

示例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!");
        }
开发者ID:gisfromscratch,项目名称:geocoding-samples,代码行数:20,代码来源:IndexFileWriterTestSuite.cs

示例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!");
 }
开发者ID:gisfromscratch,项目名称:geocoding-samples,代码行数:6,代码来源:CsvFileReaderTestSuite.cs


注:本文中的CsvFileReader.ReadFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。