VB 处理大CSV文件速度问题
各位大神请帮忙看一下如何提高大CSV文件(12M/共90000多行)的处理速度,谢谢,看了一下打开文件用了2s
分割文本用了5s
另外在picturebox画4个点阵图用了6s
打开文件
Open csv_path For Input As #1
Do While Not EOF(1)
Line Input #1, line_data
ReDim Preserve sline_data(i)
sline_data(i) = line_data
i = i + 1
Loop
Close #1分割文本
sline_split_data = Split(sline_data(i + 1), ",")
If sline_split_data(5) = "VF1" And sline_split_data(16) = "IR" And sline_split_data(17) = "LOP1" And sline_split_data(21) = "WLD1" Then
For j = i + 2 To UBound(sline_data)
sline_split_data = Split(sline_data(j), ",")
If UBound(sline_split_data) = 54 Then
ReDim Preserve X(k)
ReDim Preserve Y(k)
ReDim Preserve IV(k)
ReDim Preserve WD(k)
ReDim Preserve VF(k)
ReDim Preserve IR(k)
X(k) = Val(sline_split_data(53))
Y(k) = Val(sline_split_data(54))
IV(k) = Val(sline_split_data(17))
WD(k) = Val(sline_split_data(21))
VF(k) = Val(sline_split_data(5))
IR(k) = Val(sline_split_data(16))
If k > 0 Then
If Abs(X(k) - X(k - 1)) > 0 And Abs(X(k) - X(k - 1)) <= x_min Then
x_min = Abs(X(k) - X(k - 1))
End If
If Abs(Y(k) - Y(k - 1)) > 0 And Abs(Y(k) - Y(k - 1)) <= y_min Then
y_min = Abs(Y(k) - Y(k - 1))
End If
End If
If X(k) >= xmax Then
xmax = X(k)
End If
If X(k) <= xmin Then
xmin = X(k)
End If
If Y(k) >= ymax Then
ymax = Y(k)
End If
If Y(k) <= ymax Then
ymin = Y(k)
End If
k = k + 1
End If
Next
End If
Open csv_path For Input As #1
Do While Not EOF(1)
Line Input #1, line_data
ReDim Preserve sline_data(i)
sline_data(i) = line_data
i = i + 1
Loop
Close #1分割文本
sline_split_data = Split(sline_data(i + 1), ",")
If sline_split_data(5) = "VF1" And sline_split_data(16) = "IR" And sline_split_data(17) = "LOP1" And sline_split_data(21) = "WLD1" Then
For j = i + 2 To UBound(sline_data)
sline_split_data = Split(sline_data(j), ",")
If UBound(sline_split_data) = 54 Then
ReDim Preserve X(k)
ReDim Preserve Y(k)
ReDim Preserve IV(k)
ReDim Preserve WD(k)
ReDim Preserve VF(k)
ReDim Preserve IR(k)
X(k) = Val(sline_split_data(53))
Y(k) = Val(sline_split_data(54))
IV(k) = Val(sline_split_data(17))
WD(k) = Val(sline_split_data(21))
VF(k) = Val(sline_split_data(5))
IR(k) = Val(sline_split_data(16))
If k > 0 Then
If Abs(X(k) - X(k - 1)) > 0 And Abs(X(k) - X(k - 1)) <= x_min Then
x_min = Abs(X(k) - X(k - 1))
End If
If Abs(Y(k) - Y(k - 1)) > 0 And Abs(Y(k) - Y(k - 1)) <= y_min Then
y_min = Abs(Y(k) - Y(k - 1))
End If
End If
If X(k) >= xmax Then
xmax = X(k)
End If
If X(k) <= xmin Then
xmin = X(k)
End If
If Y(k) >= ymax Then
ymax = Y(k)
End If
If Y(k) <= ymax Then
ymin = Y(k)
End If
k = k + 1
End If
Next
End If