Re: String builder (Parsing vertically presented records)
- From: "Cor Ligthert [MVP]" <notmyfirstname@xxxxxxxxx>
- Date: Tue, 14 Mar 2006 20:06:18 +0100
IlCSP,
Why did you not go on with Cerebrus code. It is another approach, I only
wanted to tell that the SB was in my sample as well.
My sample was by the way full of typing and other errors. And because that
you are busy already so long here a better one if you don't succeed with
that of Cerebrus..
\\\
Dim strRdr As New IO.StreamReader("C:\test.txt")
Dim strWrt As New IO.StreamWriter("C:\TestO.txt")
Dim StrLine As String = strRdr.ReadLine()
StrLine = strRdr.ReadLine()
Dim sb As New System.Text.StringBuilder(StrLine.Substring(0, 9))
Do Until StrLine Is Nothing
Dim fields() As String = StrLine.Split(" "c)
If fields.Length = 2 Then
sb.Append(fields(1))
Else
sb.Append(fields(1) & "," & fields(2))
End If
StrLine = strRdr.ReadLine()
If Not StrLine Is Nothing Then
If StrLine.IndexOf("NewRegID") > -1 Then
strWrt.WriteLine(sb.ToString)
sb = New System.Text.StringBuilder(StrLine.Substring(0,
9))
StrLine = strRdr.ReadLine()
Else
sb.Append(",")
End If
End If
Loop
strWrt.WriteLine(sb.ToString)
strRdr.Close()
strWrt.Close()
///
The result withouth that crazy thirth line that you showed is.
2145551341,Y,2,N,3,Y,4,1,5,Y,6,Y,7,Y,8,Y,9,1,10,Y,11,Y,12,Y,13,Y,14,Y,15,1,16,17,Y,18,Y,19,Y,20,Y,21,1,22,N,23,N,24,1,25,2
2140164211,Y,2,Y,3,Y,4,1,5,Y,6,7,Y,8,Y,9,1,10,Y,11,N,12,Y,13,Y,14,Y,15,1,16,Y,17,18,Y,19,Y,20,Y,21,1,21,1,22,Y,23,N,24,2,25,3
I hope this helps,
Cor
.
- Follow-Ups:
- Re: String builder (Parsing vertically presented records)
- From: Cerebrus
- Re: String builder (Parsing vertically presented records)
- From: Cor Ligthert [MVP]
- Re: String builder (Parsing vertically presented records)
- References:
- Re: String builder (Parsing vertically presented records)
- From: Cerebrus
- Re: String builder (Parsing vertically presented records)
- From: Cor Ligthert [MVP]
- Re: String builder (Parsing vertically presented records)
- From: Cor Ligthert [MVP]
- Re: String builder (Parsing vertically presented records)
- Prev by Date: Re: need help with regular expression
- Next by Date: Re: Edit and Continue?? VS2005
- Previous by thread: Re: String builder (Parsing vertically presented records)
- Next by thread: Re: String builder (Parsing vertically presented records)
- Index(es):
Relevant Pages
|
Loading