用VB对大容量TXT数据截取,求解决!解决办法
用VB对大容量TXT数据截取,求解决!
大容量文本是有规律的测井数据,数据较大,几百MB的txt文本,一小小部分数据如下:
2817.3370 23 305 124.4 123.49 125.23 7 62.23 61.91 62.43
2817.3339 23 305 124.41 123.49 125.23 7 62.23 62 62.51
2817.3309 23 305 124.41 123.42 125.23 7 62.23 62 62.51
2817.3278 23 305 124.41 123.49 125.23 7 62.23 62 62.51
2817.3248 23 305 124.39 123.42 125.23 7 62.23 61.91 62.51
2817.3217 23 305 124.41 123.49 125.23 7 62.15 62 62.51
2817.3187 23 305 124.41 123.49 125.23 7 62.23 61.91 62.43
2817.3156 23 305 124.39 123.42 125.23 7 62.23 61.91 62.43
现在想截取数据,例如,深度2817.3339~2817.3217的4,5,6列数据:
2817.337 124.4 123.49 125.23
2817.3339 124.41 123.49 125.23
2817.3309 124.41 123.42 125.23
2817.3278 124.41 123.49 125.23
2817.3248 124.39 123.42 125.23
2817.3217 124.41 123.49 125.23
2817.3187 124.41 123.49 125.23
2817.3156 124.39 123.42 125.23
怎样写个VB程序截取并保存出来,谢谢大家
------解决方案--------------------
大容量文本是有规律的测井数据,数据较大,几百MB的txt文本,一小小部分数据如下:
2817.3370 23 305 124.4 123.49 125.23 7 62.23 61.91 62.43
2817.3339 23 305 124.41 123.49 125.23 7 62.23 62 62.51
2817.3309 23 305 124.41 123.42 125.23 7 62.23 62 62.51
2817.3278 23 305 124.41 123.49 125.23 7 62.23 62 62.51
2817.3248 23 305 124.39 123.42 125.23 7 62.23 61.91 62.51
2817.3217 23 305 124.41 123.49 125.23 7 62.15 62 62.51
2817.3187 23 305 124.41 123.49 125.23 7 62.23 61.91 62.43
2817.3156 23 305 124.39 123.42 125.23 7 62.23 61.91 62.43
现在想截取数据,例如,深度2817.3339~2817.3217的4,5,6列数据:
2817.337 124.4 123.49 125.23
2817.3339 124.41 123.49 125.23
2817.3309 124.41 123.42 125.23
2817.3278 124.41 123.49 125.23
2817.3248 124.39 123.42 125.23
2817.3217 124.41 123.49 125.23
2817.3187 124.41 123.49 125.23
2817.3156 124.39 123.42 125.23
怎样写个VB程序截取并保存出来,谢谢大家
------解决方案--------------------
Dim strLine As String, strItem() As String
Dim Ulimit As Double, Llimit As Double, Depth As Double
Ulimit = Val(Text1)
Llimit = Val(Text2)
Open "C:\data\1.txt" For Input As #1
Open "C:\data\2.txt" For Input As #2
Do Until EOF(1)
Line Input #1, strLine
Do While Instr(strLine, Space(2))
strLine = Replace(strLine, Space(2), Space(1))
Loop
strItem = Split(strLine, Space(1))
If Ubound(strItem) > 4 Then
Depth = Val(strItem(0))
If Depth >= Llimit And Depth <= Ulimit Then
Print #2, strItem(0) & " " & strItem(3) & " " & strItem(4) & " " & strItem(5)
End if
End if
Loop
Close #2
Close #1