作者ricaro ( )
看板C_Sharp
标题Re: [问题] 请问如何搜寻特定资料复制输出
时间Tue Mar 26 11:20:35 2013
※ 引述《ricaro ( )》之铭言:
: ※ 引述《ricaro ( )》之铭言:
: : 原始资料如下
: : ----
: : Peak Type a0 a1 a2 a3
: : 1 BG1st[UDF4] 5.83484411 -0.0689749
: : 2 Voigt Amp 1.53274934 -19.800359 0.47166280 0.14278921
: : Measured Values
: : Peak Type Amplitude Center FWHM Asym50 FW Base
: : 1 BG1st[UDF4] 7.29711128 -21.200000 0.00000000 0.00000000
: : 2 Voigt Amp 1.53274934 -19.800359 0.85969834 1.00000000
: : Peak Type Anlytc Area % Area Int Area % Area
: : 1 BG1st[UDF4] Unknown 18.0272318 92.6194949
: : 2 Voigt Amp 1.49472135 1.43652346 7.38050513
: : Total 19.4637553 100.000000
: : ----
: : 我的程式是下面这样
: : 已经把资料内容弄成string array
: : 但是要输出想要资料的时候还是有问题
: : ex. 我想要输出有关peak 2的a0 a1 a2 a3及 Int Area
: : 要输出哪个peak的资料 我是弄成由使用者来输入决定 因为要的资料不一定都是peak 2
: 目前做到挑出含有所需资料的列
: 接下来是想说把挑出来的列再弄成string array
: 然後再想办法把想要的资料输出
: 不过 我用下面的程式想把挑出来的资料转成string array
: 输出後却是空白的 冏
: 不知道是哪里出错 希望各位能指点一下
: 谢谢
这是挑出来的结果 第一个for (i..)的回圈再加上if (array..Contains(peak))
-------
2 Voigt Amp 1.53274934 -19.800359 0.47166280 0.14278921
2 Voigt Amp 1.53274934 -19.800359 0.85969834 1.00000000
2 Voigt Amp 1.49472135 1.43652346 7.38050513
Peak 2 Voigt Amp
-------
要再加第二层for 把上面的string再转成array 就失败了
arrayStrings[i]是包含关键字(peak,是由使用者输入决定)的字串
rowords[] 我希望是arrayStrings[i]再转成array後的结果
这样我就能挑选我要的数据输出
: : ------
: for (int i = 0; i != (arrayStrings.Length); i++)//i=row# in the file
: {
: if (arrayStrings[i].Contains(peak))
: {
: StreamWriter datainput = output.AppendText();
: string[] rowords = arrayStrings[i].Split(' ');
: for (int j = 0 ; j!=arrayStrings[i].Length ; j++)
: {
: datainput.WriteLine(rowords[j]);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
我debug後 出现的讯息是 "清单索引的最大值必须小於清单的大小"
rowords[j]的维度是21 但arrayStrings[i].Length是70
应该是这里出问题 还想不透到底是为啥产生这种状况
: }
: datainput.Flush();
: datainput.Close();
: }
: }
: : ----------
再次感谢 各位能有耐心看完
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.116.22.21
1F:→ ssccg:Length 70是代表有70个char,又不是split後会是70个string 03/26 12:55
2F:→ ssccg:明明在loop rowords,为什麽不用rowords.Length ? 03/26 12:56
3F:→ ricaro:感谢! 一语惊醒梦中人~我试看看 03/26 13:50