Home > Database > Mysql Tutorial > body text

.net CsvHelper 2.0

WBOY
Release: 2016-06-07 15:44:27
Original
1535 people have browsed it

http://joshclose.github.io/CsvHelper/ var outputmatchPath = System.Configuration.ConfigurationManager.AppSettings[//FilePath]; TextReader requiredMatchElementsfileReader = File.OpenText(outputmatchPath); var matchCsv = new CsvReader(requir

http://joshclose.github.io/CsvHelper/



var outputmatchPath = System.Configuration.ConfigurationManager.AppSettings["//FilePath"];

TextReader requiredMatchElementsfileReader = File.OpenText(outputmatchPath);

var matchCsv = new CsvReader(requiredMatchElementsfileReader);


matchCsv.Configuration.RegisterClassMapRequiredMatchElementsMap>();
var requiredMatchList = matchCsv.GetRecordsRequiredMatchElements>().ToList();



    public class RequiredMatchElements
    {
        public int IngredientId { set; get; }


        public string IngredientName { set; get; }


        public string RequriedElementsString { set; get; }
    }


    public class RequiredMatchElementsMap : CsvClassMap
    {
        public override void CreateMap()
        {
            Map(m => m.IngredientId).Name("IngredientId");
            Map(m => m.IngredientName).Name("IngredientName");
            Map(m => m.RequriedElementsString).Name("RequriedElementsString");
        }


    }


Write




            using (TextWriter streamWriter =
            new StreamWriter(HttpContext.Current.Server.MapPath("/App_Data/Top5000Instagram.csv")))
            {


                var csv = new CsvWriter(streamWriter);
                csv.WriteRecords(dateList);
            }





Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!