public System.Data.DataTable GetInstitutes(List <string> fields) { DataTable result = InstituteDataTable.Create(); foreach (var item in fields) { DataRow row = result.NewRow(); string field = CheckSchool(item); if (!string.IsNullOrEmpty(item)) { int index = field.IndexOf(','); if (index != -1) { row["一级机构"] = field.Substring(0, index); row["二级机构"] = field.Substring(index + 1); } else { row["一级机构"] = field; row["二级机构"] = string.Empty; } result.Rows.Add(row); } } return(result); }
/// <summary> /// 从csv文件中读取规范表 /// </summary> /// <param name="filename"></param> /// <returns></returns> public static DataTable Import1(string filename) { DataTable NormTable = InstituteDataTable.Create(); using (StreamReader reader = new StreamReader(filename, Encoding.UTF8)) { string line = reader.ReadLine(); while ((line = reader.ReadLine()) != null) { string[] fields = line.Split(new string[] { "\",\"", null }, StringSplitOptions.None); if (fields.Length > 4) { DataRow dr = NormTable.NewRow(); string university = fields[0].TrimStart('"'); dr[0] = university; dr[1] = fields[1]; dr[2] = fields[2]; dr[3] = fields[3]; dr[4] = fields[4].TrimEnd('"');; NormTable.Rows.Add(dr); } } reader.Close(); } return(NormTable); }
public System.Data.DataTable GetInstitutes(List <string> fields) { DataTable table = InstituteDataTable.Create(); foreach (var field in fields) { if (!string.IsNullOrEmpty(field)) { DataRow dr = table.NewRow(); string parentInstitute = GetParentInsitute(field); string institute = field.Replace(parentInstitute, "").Trim(',').Trim(); dr[0] = parentInstitute; dr[1] = base.RemoveComma(institute); table.Rows.Add(dr); } } return(table); }
public static DataTable Import(string filename) { DataTable table = InstituteDataTable.Create(); List <NormalInstituteRecord> list = ImportToList(filename); if (list == null || list.Count == 0) { return(table); } foreach (var item in list) { DataRow dr = table.NewRow(); dr[0] = item.一级机构; dr[1] = item.二级机构; dr[2] = item.学科规范; dr[3] = item.学院规范; dr[4] = item.学校规范; table.Rows.Add(dr); } return(table); }
/// <summary> /// 创建二级机构表 /// </summary> /// <returns></returns> public DataTable CreateInstituteDataTable() { return(InstituteDataTable.Create()); }