txt文件中文本的提取,急!!!!!!!!!!!!!!!!!!!

jyjb 2005-12-23 12:02:51
现有文件内容如下
NSTL 国 家 科 技 图 书 文 献 中 心

所属馆藏:


外文学位论文数据库

   【正题名】:Cyclic stress-strain response and dislocation substructure evolution of nickel.
    【作者】:Jia, Yan.
  【作者单位】:Clarkson University.
 【学位授予年】:2002
 【论文集名称】:Dissertation Abstracts International
    【卷期】:vol.62-11B.
    【ISBN】:0493450653
    【页码】:p.5334
   【总页数】:170
  【授予学位】:ph.D.
【授予学位单位】:Clarkson University.
  【导师姓名】:Moosbrugger, John C.
  【研究专业】:Engineering, Mechanical.; Engineering, Metallurgy.
  【培养单位】:Clarkson University.
   【馆藏号】:AAI3032513
   【分类号】:TH; TF
  【正文语种】:eng
    【文摘】:The cyclic stress-strain response and substructure evolution of initiallyannealed pure nickel (high stacking fault energy FCC material) were studied by



NSTL 国 家 科 技 图 书 文 献 中 心

所属馆藏:


外文学位论文数据库

   【正题名】:Equity and distribution of resources and performance across elementary andmiddle schools within large urban school districts: Evidence from New York City.
    【作者】:Iatarola, patrice.
  【作者单位】:New York University.
 【学位授予年】:2002
 【论文集名称】:Dissertation Abstracts International
    【卷期】:vol.62-11A.
    【ISBN】:0493472924
    【页码】:p.3697
   【总页数】:324
  【授予学位】:ph.D.
【授予学位单位】:New York University.
  【导师姓名】:Stiefel, Leanna
  【研究专业】:Education, Finance.; political Science, public Administration.; Education,Administration.
  【培养单位】:New York University.
   【馆藏号】:AAI3034578
   【分类号】:F8-4; D0; G4
  【正文语种】:eng
    【文摘】:This study examines the distribution of resources and outputs across elementaryand middle school students in New York City's public schools. New York City
我要将 【】:后的内容提取出来,请教好办法

...全文
252 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
ChengKing 2005-12-23
  • 打赏
  • 举报
回复
先读出一行,再对字符串解析出你想要的字串.

参考:
读写文件:

public ReadFile(string strFileName)
{
StreamReader sr = new StreamReader(strFileName),System.Text.Encoding.Default);
while (sr.Peek() >= 0)
{
Console.WriteLine(sr.ReadLine());
}
sr.Close();
}

Public Shared Sub WriteFile(ByVal strLog As String, ByVal page As System.Web.UI.Page)
If Directory.Exists(page.Server.MapPath("LogFolder")) = False Then
Directory.CreateDirectory(page.Server.MapPath("LogFolder"))
End If
Dim pw As StreamWriter = New StreamWriter(page.Server.MapPath(".") & "\LogFolder\log.txt", True, System.Text.Encoding.UTF8)
pw.WriteLine(strLog)
pw.Flush()
pw.Close()
End Sub
止戈而立 2005-12-23
  • 打赏
  • 举报
回复
把txt文件读出来放在一个string input里面。。

using System.Text.RegularExpressions;
string input=this.textBox4.Text;
input=input.Replace("【","<");
input=input.Replace("】",">");
string pa=@"<.*?>:(.*?\r\n)";
Regex reg=new Regex(pa);
string output=reg.Replace(input,"$1");
jijl2001 2005-12-23
  • 打赏
  • 举报
回复
这样好处在于不用判断字符串,速度稍微快点,缺点是(-1 == s.IndexOf("】:"))或许是在某一行中有,那就玩完了
jijl2001 2005-12-23
  • 打赏
  • 举报
回复
using (StreamReader sr = new StreamReader(dirs[k],System.Text.Encoding.GetEncoding("GB2312")))
{
int i=1;
while (sr.Peek() >= 0)
{
string s = sr.ReadLine().Trim();
if (-1 == s.IndexOf("】:"))//没有字段的情况
{
continue;
}
else
{
switch(i)
{
case 1:
{
//操作
i++;
break;
}
case 2:
{

}
case 18:
{
//因为有18项所以在这,把i=1,然后写数据库
}
}
}
cw888 2005-12-23
  • 打赏
  • 举报
回复
合理采用正则表达式,很快的
copall 2005-12-23
  • 打赏
  • 举报
回复
就按【和】和:分割咯,取【 】之间的值跟字段名判断一下
copall 2005-12-23
  • 打赏
  • 举报
回复
string contentString="";
if (System.IO.File.Exists(filePath))
{
System.IO.StreamReader sr= new System.IO.StreamReader(filePath,System.Text.Encoding.Default);
while(sr.Peek()>=0)
{
string lineString=sr.ReadLine();
string[] contentList=lineString.Split(':');
contentString+=contentList[1];
}
sr.Close();
}
cncxz 2005-12-23
  • 打赏
  • 举报
回复
想不到其他更快的方法,如果想加快进度,建议楼主使用多线程
jyjb 2005-12-23
  • 打赏
  • 举报
回复
这个方法我知道,因为也许有几万个这样子的文件,我要把这些文件中的内容导入到数据库
【正题名】:这样子的为字段名。一个文件中有10条这种记录,我想找一个快一点的

110,536

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧