如何提高文件读写速度?
一个CSV文件,约25兆,200000(二十万)行左右,对这个文件进行读写成一个新的文件,我的程序如下,附件为CSV文件,在我的电脑上大概需要8秒左右,还能快些吗?最快能多快?程序代码:
Private Sub Command1_Click() Dim strWj As String Dim strJ() As String Dim aryContent() As Byte Dim tmp() As String Dim i As Long Dim j As Long tttt = Timer Open "c:\1.csv" For Binary As #1 ReDim aryContent(LOF(1) - 1) Get #1, , aryContent Close #1 Open "c:\temp.txt" For Append As #2 strWj = StrConv(aryContent, vbUnicode) strJ = Split(strWj, vbCrLf) For i = 0 To UBound(strJ) If IsNumeric(Left(strJ(i), 1)) = True Then tmp() = Split(strJ(i), ",") If tmp(2) = "True" Then Print #2, tmp(5) & vbTab & tmp(6) & vbTab & tmp(16) & vbTab & tmp(20) & vbTab & tmp(23) & vbTab & tmp(24) End If End If Next i Close #2 MsgBox Timer - tttt End Sub
1.rar
(3.79 MB)