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


C# CsvReader.MoveTo方法代码示例

本文整理汇总了C#中CsvReader.MoveTo方法的典型用法代码示例。如果您正苦于以下问题:C# CsvReader.MoveTo方法的具体用法?C# CsvReader.MoveTo怎么用?C# CsvReader.MoveTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CsvReader的用法示例。


在下文中一共展示了CsvReader.MoveTo方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetNextComic

        private static Comic GetNextComic()
        {
            var nextComicIndex = Random.Next(1, 400);

            using (var csv = new CsvReader(new StreamReader("comics.csv"), false))
            {
                csv.MoveTo(nextComicIndex);
                return new Comic
                {
                    Title = csv[2],
                    Publisher = csv[1],
                    ReleaseDate = csv[0]
                };
            }
        }
开发者ID:daffers,项目名称:Gelf4NLog,代码行数:15,代码来源:Program.cs

示例2: Model_Shown

        private void Model_Shown(object sender, EventArgs e)
        {
            // Load in brand table
            dataGridViewModel.ReadOnly = true;
            dataGridViewMaker.ReadOnly = true;
            using (CsvReader csv = new CsvReader(new StreamReader(filePathBrand), true, ';'))
            {
                int n = csv.FieldCount;
                int i = 0;
                while (csv.ReadNextRecord())
                {
                    dataGridViewMaker.Rows.Add();
                    dataGridViewMaker.Rows[i].Cells[0].Value = i + 1;
                    for (int j = 0; j < n; j++)
                    {
                        dataGridViewMaker.Rows[i].Cells[j + 1].Value = csv[j];
                    }
                    i++;
                }
            }

            // first id brand in table
            int k = int.Parse(dataGridViewMaker.Rows[0].Cells[1].Value.ToString());

            // Load in model table
            using (CsvReader csv = new CsvReader(new StreamReader(filePathMoels), true, ';'))
            {
                int n = csv.FieldCount;
                int i = 0;
                if (k != 0)
                {
                    csv.MoveTo(n - 1);
                    while (csv.ReadNextRecord())
                    {
                        if (int.Parse(csv[1]) == k)
                        {
                            dataGridViewModel.Rows.Add();
                            dataGridViewModel.Rows[i].Cells[0].Value = i + 1;
                            dataGridViewModel.Rows[i].Cells[2].Value = csv[2];
                            i++;
                        }
                    }
                }
                else
                {
                    dataGridViewModel.Rows.Add();
                    dataGridViewModel.Rows[0].Cells[0].Value = "-";
                    dataGridViewModel.Rows[0].Cells[0].Value = "Нема записів";
                }

            }
        }
开发者ID:VikaBoboshko,项目名称:Car,代码行数:52,代码来源:Model.cs

示例3: ParseCSV

        public void ParseCSV(DotNetNuke.Services.FileSystem.FileInfo fileInfo, int startIndex)
        {
            using (CsvReader reader = new CsvReader(new StreamReader(fileInfo.PhysicalPath), true))
            {
                int tabModuleId = DataProvider.Instance().GetTabModuleIdByFileId(fileInfo.FileId);
                int lineNumber = 0;

                if (startIndex == 0)
                {
                    DataProvider.Instance().ClearTempLocations();
                }
                else
                {
                    lineNumber = startIndex;
                    reader.MoveTo(startIndex - 1);
                }

                try
                {
                    while (reader.ReadNextRecord())
                    {
                        lineNumber++;
                        Location location = new Location();
                        location.LocationId = Convert.ToInt32(GetValue(reader, "UNIQUE_KEY"), CultureInfo.InvariantCulture);
                        location.ExternalIdentifier = GetValue(reader, "EXTERNAL_IDENTIFIER");
                        location.Name = GetValue(reader, "LOCATION_NAME");
                        string address1 = GetValue(reader, "ADDRESS1");
                        string address2 = GetValue(reader, "ADDRESS2");
                        location.City = GetValue(reader, "CITY");
                        string state = GetValue(reader, "STATE");
                        location.PostalCode = GetValue(reader, "ZIP");
                        location.Phone = GetValue(reader, "PHONE_NUMBER");
                        location.LocationDetails = GetValue(reader, "LOCATION_DETAILS");
                        location.Website = GetValue(reader, "WEBSITE");
                        location.PortalId = this.portalId;
                        string locationType = GetValue(reader, "TYPE_OF_LOCATION");
                        if (locationType == string.Empty)
                        {
                            locationType = "Default";
                        }

                        string country = GetValue(reader, "COUNTRY");
                        DataTable dt = DataProvider.Instance().GetLocationTypes();
                        int locationTypeId = -1;

                        foreach (DataRow dr in dt.Rows)
                        {
                            if (Convert.ToString(dr["LocationTypeName"], CultureInfo.InvariantCulture) == locationType)
                            {
                                locationTypeId = Convert.ToInt32(dr["LocationTypeID"], CultureInfo.InvariantCulture);
                                location.LocationTypeId = locationTypeId;
                            }
                        }

                        if (locationTypeId == -1)
                        {
                            locationTypeId = DataProvider.Instance().InsertLocationType(locationType);
                            location.LocationTypeId = locationTypeId;
                        }

                        location.RegionId = ResolveState(state);
                        if (location.RegionId < 1)
                        {
                            location.RegionId = Convert.ToInt32(null, CultureInfo.InvariantCulture);
                        }

                        location.CountryId = ResolveCountry(country);
                        if (location.CountryId < 1)
                        {
                            ModuleController objModules = new ModuleController();
                            location.CountryId = Dnn.Utility.GetIntSetting(objModules.GetTabModuleSettings(tabModuleId), "DefaultCountry").Value;
                        }

                        location.CsvLineNumber = lineNumber;
                        location.Address = address1;

                        // Address2 is informational only - See Pat Renner.
                        location.Address2 = address2;

                        GeocodeResult geocodeResult = GetGeoCoordinates(tabModuleId, address1, location.City, location.RegionId, location.PostalCode, location.CountryId);
                        if (geocodeResult.Successful)
                        {
                            location.Latitude = geocodeResult.Latitude;
                            location.Longitude = geocodeResult.Longitude;
                        }

                        location.Approved = true;

                        try
                        {
                            location.SaveTemp(geocodeResult.Successful);
                        }
                        catch (SqlException ex)
                        {
                            Exceptions.LogException(ex);
                        }
                    }
                }
                catch (ArgumentException exc)
                {
//.........这里部分代码省略.........
开发者ID:EngageSoftware,项目名称:Engage-Locator,代码行数:101,代码来源:DataImportScheduler.cs

示例4: MoveToTest5

 public void MoveToTest5()
 {
     using (CsvReader csv = new CsvReader(new StringReader(CsvReaderSampleData.SampleData1), false))
     {
         Assert.IsTrue(csv.MoveTo(-1));
         csv.MoveTo(0);
         Assert.IsFalse(csv.MoveTo(-1));
     }
 }
开发者ID:jboolean,项目名称:RIT-Bus,代码行数:9,代码来源:CsvReaderTest.cs

示例5: MoveToTest4

        public void MoveToTest4()
        {
            using (CsvReader csv = new CsvReader(new StringReader(CsvReaderSampleData.SampleData1), true))
            {
                csv.SupportsMultiline = false;

                string[] headers = csv.GetFieldHeaders();

                Assert.IsTrue(csv.MoveTo(2));
                Assert.AreEqual(2, csv.CurrentRecordIndex);
                CsvReaderSampleData.CheckSampleData1(csv, false);
            }
        }
开发者ID:jboolean,项目名称:RIT-Bus,代码行数:13,代码来源:CsvReaderTest.cs

示例6: MoveToTest3

 public void MoveToTest3()
 {
     using (CsvReader csv = new CsvReader(new StringReader(CsvReaderSampleData.SampleData1), true))
     {
         Assert.IsFalse(csv.MoveTo(CsvReaderSampleData.SampleData1RecordCount));
     }
 }
开发者ID:jboolean,项目名称:RIT-Bus,代码行数:7,代码来源:CsvReaderTest.cs

示例7: MoveToTest1

 public void MoveToTest1()
 {
     using (CsvReader csv = new CsvReader(new StringReader(CsvReaderSampleData.SampleData1), true))
     {
         for (int i = 0; i < CsvReaderSampleData.SampleData1RecordCount; i++)
         {
             Assert.IsTrue(csv.MoveTo(i));
             CsvReaderSampleData.CheckSampleData1(i, csv);
         }
     }
 }
开发者ID:jboolean,项目名称:RIT-Bus,代码行数:11,代码来源:CsvReaderTest.cs

示例8: MoveToTest2

 public void MoveToTest2()
 {
     using (CsvReader csv = new CsvReader(new StringReader(CsvReaderSampleData.SampleData1), true))
     {
         csv.MoveTo(1);
         csv.MoveTo(0);
     }
 }
开发者ID:chilversc,项目名称:CsvReader,代码行数:8,代码来源:CsvReaderTest.cs

示例9: ArgumentTestMoveTo1

 public void ArgumentTestMoveTo1()
 {
     using (CsvReader csv = new CsvReader(new StringReader(CsvReaderSampleData.SampleData1), false))
     {
         csv.MoveTo(-1);
     }
 }
开发者ID:chilversc,项目名称:CsvReader,代码行数:7,代码来源:CsvReaderTest.cs

示例10: comboBoxBrand_SelectedIndexChanged

        private void comboBoxBrand_SelectedIndexChanged(object sender, EventArgs e)
        {
            groupBoxComplex.Enabled = true;
            dataGridViewModels.Rows.Clear();
            string brand = "";
            brand = comboBoxBrand.SelectedItem.ToString();
            for (int i = 0; i < Brandlist.Count; i++)
            {
                if (brand.CompareTo(Brandlist[i].name) == 0)
                {
                    IdBrand = Brandlist[i].n;
                    break;
                }
            }
            CsvReader csvBaseProperties = new CsvReader(new StreamReader("baseProperties.csv"), true, ';');
            string model = "";
            using (CsvReader csv = new CsvReader(new StreamReader("Car.csv"), true, ';'))
            {
                int i = 0;
                int k_b = 0;
                int k_m = 0;
                int jj = 0;

                while (csv.ReadNextRecord())
                {
                    if (csv[1] == IdBrand && IdBrand != "")
                    {
                        csvBaseProperties.MoveTo(k_b);

                        IdBaseProperties = csv[6];
                        IdModels = csv[2];
                        IdType = csv[4];
                        IdColor = csv[5];
                        while (csvBaseProperties.ReadNextRecord())
                        {
                            if (csvBaseProperties[0] == IdBaseProperties && IdBaseProperties != "")
                            {
                                dataGridViewModels.Rows.Add();
                                dataGridViewModels.Rows[i].Cells[0].Value = i + 1;
                                for (int j = 0; j < csvBaseProperties.FieldCount; j++)
                                {
                                    dataGridViewModels.Rows[i].Cells[j + 5].Value = csvBaseProperties[j].ToString();
                                }
                                i++;
                                break;
                            }
                            k_b++;
                        }
                        CsvReader csvModels = new CsvReader(new StreamReader("Models.csv"), true, ';');
                        while (csvModels.ReadNextRecord())
                        {
                            if (csvModels[0] == IdModels && IdModels != "")
                            {
                                model = csvModels[2];
                                break;
                            }
                        }
                        dataGridViewModels.Rows[i - 1].Cells[4].Value = model;
                        dataGridViewModels.Rows[i - 1].Cells[2].Value = IdType;
                        dataGridViewModels.Rows[i - 1].Cells[3].Value = IdColor;
                        dataGridViewModels.Rows[i - 1].Cells[1].Value = IdModels;

                    }
                }
            }
        }
开发者ID:VikaBoboshko,项目名称:Car,代码行数:66,代码来源:ViewModels.cs


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