Hello,
I have some code that reads each line of a text file, and if a line is
found where the length of the string in the line is 384, it writes
the line to a text file.
The other step that I need to take is to delete the line from the
source file. The code is as follows;
-*************** *************** ***********
Public Sub Main()
'find the records where the string length is greater than 384
'write them out to a file
'delete them from the source file
Dim oFile As System.IO.File
Dim oRead As System.IO.Strea mReader
Dim oWrite As System.IO.Strea mWriter
Dim LineIn As String
oRead =
oFile.OpenText( "C:\Learning\Se ttlementDataTes t\SC15_Copies\S ingleFile\CDNSC .CDNSC.SC00015. 11062006")
oWrite =
oFile.CreateTex t("C:\Learning\ SettlementDataT est\SC15_Copies \ErrantRecords\ ErrantRecords.t xt")
While oRead.Peek <-1
LineIn = oRead.ReadLine( )
If Len(LineIn) 384 Then
oWrite.WriteLin e(LineIn)
'what do I do here to delete the 'LineIn' from the
source file?
End If
End While
oRead.Close()
oWrite.Close()
oFile = Nothing
LineIn = Nothing
Dts.TaskResult = Dts.Results.Suc cess
End Sub
-*************** *************** *******
What would I do to delete the 'LineIn' found in the condition? By the
way, I'm doing this in a Script Task of a Integration Services package.
Thank you for your help!
cdun2
I have some code that reads each line of a text file, and if a line is
found where the length of the string in the line is 384, it writes
the line to a text file.
The other step that I need to take is to delete the line from the
source file. The code is as follows;
-*************** *************** ***********
Public Sub Main()
'find the records where the string length is greater than 384
'write them out to a file
'delete them from the source file
Dim oFile As System.IO.File
Dim oRead As System.IO.Strea mReader
Dim oWrite As System.IO.Strea mWriter
Dim LineIn As String
oRead =
oFile.OpenText( "C:\Learning\Se ttlementDataTes t\SC15_Copies\S ingleFile\CDNSC .CDNSC.SC00015. 11062006")
oWrite =
oFile.CreateTex t("C:\Learning\ SettlementDataT est\SC15_Copies \ErrantRecords\ ErrantRecords.t xt")
While oRead.Peek <-1
LineIn = oRead.ReadLine( )
If Len(LineIn) 384 Then
oWrite.WriteLin e(LineIn)
'what do I do here to delete the 'LineIn' from the
source file?
End If
End While
oRead.Close()
oWrite.Close()
oFile = Nothing
LineIn = Nothing
Dts.TaskResult = Dts.Results.Suc cess
End Sub
-*************** *************** *******
What would I do to delete the 'LineIn' found in the condition? By the
way, I'm doing this in a Script Task of a Integration Services package.
Thank you for your help!
cdun2
Comment