/// <summary> /// CSVを読み込み、薬品情報のリストを返す /// </summary> /// <param name="path">CSVファイルの絶対パス</param> /// <returns>薬品情報のリスト</returns> static List<Yakuhin> ReadCsv(string path) { List<Yakuhin> list = new List<Yakuhin>(); var enc = new System.Text.UTF8Encoding(false); using (var reader = new System.IO.StreamReader(path, enc)) { var csv = new CsvHelper.CsvReader(reader); while (csv.Read()) { string drugCode = csv.GetField<string>(0); string clsCode = csv.GetField<string>(1); string clsName = csv.GetField<string>(2); string drugName = csv.GetField<string>(3); string company = csv.GetField<string>(4); var yakuhin = new Yakuhin { DrugCode = drugCode, ClassificationCode = clsCode, ClassificationName = clsName, DrugName = drugName, Company = company }; list.Add(yakuhin); } } return list; }
/// <summary> /// CSVを読み込み、薬品情報のリストを返す /// </summary> /// <param name="path">CSVファイルの絶対パス</param> /// <returns>薬品情報のリスト</returns> static List <Yakuhin> ReadCsv(string path) { List <Yakuhin> list = new List <Yakuhin>(); var enc = new System.Text.UTF8Encoding(false); using (var reader = new System.IO.StreamReader(path, enc)) { var csv = new CsvHelper.CsvReader(reader); while (csv.Read()) { string drugCode = csv.GetField <string>(0); string clsCode = csv.GetField <string>(1); string clsName = csv.GetField <string>(2); string drugName = csv.GetField <string>(3); string company = csv.GetField <string>(4); var yakuhin = new Yakuhin { DrugCode = drugCode, ClassificationCode = clsCode, ClassificationName = clsName, DrugName = drugName, Company = company }; list.Add(yakuhin); } } return(list); }