• 文件拼接快速批处理文件


    遇到一个问题,有三个word文档,要求每个文档里提取一条信息和另外的word文档组合,形成一条新的信息,存入txt文件。

     1  path q = new path();//path类,用来存放路径;
     2         public string wenti(int i, int l) //提取第i行的问题,从wenti l.txt提取;
     3         {
     4             StreamReader wenti = new StreamReader(""+q.questionpath+"wenti" + l + ".txt", Encoding.GetEncoding("GB2312"));
     5             string sLine = "";
     6             ArrayList wentiList = new ArrayList();
     7             while (sLine != null)
     8             {
     9                 sLine = wenti.ReadLine();
    10                 if (sLine != null && !sLine.Equals(""))
    11                     wentiList.Add(sLine);
    12             }
    13             wenti.Close();
    14             string wenti2 = (string)wentiList[i];
    15             return wenti2;
    16         }
    17         public string daan(int i, int l)//提取第i行答案,从daanl.txt提取;
    18         {
    19             StreamReader daan = new StreamReader("" + q.questionpath + "daan" + l + ".txt", Encoding.GetEncoding("GB2312"));
    20             string[] daan1 = daan.ReadLine().ToString().Split('^');
    21 
    22             daan.Close();
    23             return daan1[i];
    24           
    25         }
    26         public string duihua(int i, int l)//提取i行信息,从duihual.txt读取;
    27 { 28 StreamReader duihua = new StreamReader("" + q.questionpath + "duihua" + l + ".txt", Encoding.GetEncoding("GB2312")); 29 string sLine = ""; 30 ArrayList duihualist = new ArrayList(); 31 while (sLine != null) 32 { 33 sLine = duihua.ReadLine(); 34 if (sLine != null && !sLine.Equals("")) 35 duihualist.Add(sLine); 36 } 37 duihua.Close(); 38 string duihua2 = (string)duihualist[i]; 39 return duihua2; 40 } 41 int i = 0; 42 public void greatfile(int id, int l) 43 { 44 FileStream px = new FileStream(""+q.questionpath+"" + id + ".txt", FileMode.Create); 45 StreamWriter file = new StreamWriter(px, Encoding.Default); 46 47 file.WriteLine("" + id + "^" + wenti(i, l) + "" + daan(i, l) + "^" + duihua(i, l) + "^" + id + ""); 48 49 file.Close(); 50 px.Close(); 51 i++; 52 }

    先把每个word文档用到的信息提取出来,再通过程序批处理这些问题。

  • 相关阅读:
    20200226 Java IO流——廖雪峰
    20200225 Java 多线程(2)-廖雪峰
    20200225 Java 多线程(1)-廖雪峰
    20200224 尚硅谷ElasticSearch【归档】
    20200224 一 概述
    20200222 尚硅谷Dubbo【归档】
    20200222 四、dubbo原理
    Improved robustness of reinforcement learning policies upon conversion to spiking neuronal network platforms applied to Atari Breakout game
    Reinforcement learning in populations of spiking neurons
    Solving the Distal Reward Problem through Linkage of STDP and Dopamine Signaling
  • 原文地址:https://www.cnblogs.com/wandd/p/2701705.html
Copyright © 2020-2023  润新知