当前位置:编程学习 > VB >>

从大量txt文件中提取带有指定字符的数据列

我有大量txt文件
每一个文件中数据量很大
只想提取其中带有字符 POR  PREM  SW 这三个字符所在的列数据 表头不要(表头共6行) 
每一个文件POR  PREM  SW  所在的列并不一样 
所以给问题增加了一点点难度 
请大虾解决 急用

由于是新手,暂时没有分数 等赚到一定报答 --------------------编程问答-------------------- open "test.txt" for input as #1
open "newfile.txt" for output as #2
do until eof(1)
for i = 1 to 6
line input #1, strline
next i
line input #1, strline
if (instr(strline, "POR") > 0) or (instr(strline, "PREM") > 0) or (instr(strline, "SW") > 0) then
print #2, strline
endif
loop
close #2
close #1 --------------------编程问答-------------------- 谢谢 
运行到 Line Input #1, strline
显示输入超出文件尾 咋办阿? --------------------编程问答-------------------- open "test.txt" for input as #1 
open "newfile.txt" for output as #2 
for i = 1 to 6 
if not eof(1) then line input #1, strline 
next i
do until eof(1) 
line input #1, strline 
if (instr(strline, "POR") > 0) or (instr(strline, "PREM") > 0) or (instr(strline, "SW") > 0) then 
print #2, strline 
endif 
loop 
close #2 
close #1 --------------------编程问答-------------------- FORWARD_TEXT_FORMAT_1.0                                                                                                                                                                                           
STDEP =  1900.0000                                                                                                                                                                                                
ENDEP =  2256.8799                                                                                                                                                                                                
RLEV  =     0.1250                                                                                                                                                                                                
CURVENAME =  GR, AC, RILD, RILM, RLL8, SP, CAL, DEVI, AZIM, POR, PORW, BULK, PORT, PORF, PERM, HF, PF, SW, SH, CALC, CL, PORX, PORH, RWA, RMFA, sog, s1, s2, c1, r2, r1, TVD, XE, YN, HOFS, HOAZ, AZZ, VAC, VBULK,
END                                                                                                                                                                                                               
#DEPTH            GR         AC       RILD       RILM       RLL8         SP        CAL       DEVI       AZIM        POR       PORW       BULK       PORT       PORF       PERM         HF         PF         SW   
1900.0000      82.812    211.447     27.553     31.635     37.241    101.676     21.724     12.938    240.748      0.001      0.001      0.000      0.001      0.001      0.010      0.000      0.217    100.000  
1900.1250      81.108    210.335     28.113     32.038     40.068    102.009     21.755     12.936    240.708      0.001      0.001      0.000      0.001      0.001      0.010      0.000      0.217    100.000  
1900.2500      80.920    210.190     28.362     31.407     40.035    102.641     21.751     12.938    240.660      0.001      0.001      0.000      0.001      0.001      0.010      0.000      0.217    100.000  
1900.3750      82.417    211.207     28.364     30.088     36.904    103.522     21.721     12.942    240.628      0.001      0.001      0.000      0.001      0.001      0.010      0.000      0.217    100.000  
1900.5000      86.836    213.090     28.229     28.646     32.549    104.588     21.685     12.948    240.596      0.001      0.001      0.000      0.001      0.001      0.010      0.000      0.217    100.000  
1900.6250      94.166    215.186     28.040     27.559     28.968    105.801     21.663     12.954    240.572      0.001      0.001      0.000      0.001      0.001      0.010      0.000      0.217    100.000  
1900.7500     101.317    216.766     27.806     26.979     27.085    107.096     21.670     12.964    240.548      0.001      0.001      0.000      0.001      0.001      0.010      0.000      0.218    100.000  
1900.8750     104.666    217.531     27.471     26.721     26.593    108.381     21.702     12.976    240.532      0.001      0.001      0.000      0.001      0.001      0.010      0.000      0.218    100.000   --------------------编程问答-------------------- 数据文件类似于这样的  请大侠多多帮助  粘贴到ultra就可以看分列
补充:VB ,  基础类
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,