The following VB code was used to parse a
tab-delimited text file, exported from Microsoft access. This
code removes all lines that contain ‘total’
Also, the row containing the name is deleted,
and the name is appended to the respective rows.
It’s kind of a hack, but it was for a
one-time use. Also, we made sure that no personal or business
names had ‘total’ anywhere in them. The code takes less
than a second to run through 2500+ rows. Our good friends at
Habitat for Humanities were going through these rows 1 by 1.
They think that the Software group walks on
water now.
Dim tline As String
Dim cname As String
Dim nline As String
Dim i As Integer
FileOpen(1, "c:\hab\Donation.txt",
OpenMode.Input)
FileOpen(2, "c:\hab\habmod1.txt", OpenMode.Output)
tline = LineInput(1)
PrintLine(2, tline)
tline = LineInput(1)
PrintLine(2, tline)
While Not EOF(1)
tline = LineInput(1)
linelbl.Text = tline
i = -1
While i <> 0
i = InStr(1, tline, "Total", CompareMethod.Text)
If i <> 0 Then
tline = LineInput(1)
End If
End While
While i <> 0
i = InStr(1, tline, "Field14:", CompareMethod.Text)
If i <> 0 Then
tline = LineInput(1)
End If
End While
myarray = Split(tline, Chr(9))
If myarray(0) <> "" Then
If myarray(0).Substring(0, 1) = Chr(34) Then
cname = myarray(0)
End If
Else
myarray(0) = cname
nline = ""
For i = 0 To UBound(myarray) - 1
nline = nline & myarray(i) & Chr(9)
Next
nline = nline & myarray(UBound(myarray))
PrintLine(2, nline)
End If