scorpion53061
MIS
This code removes all blank lines from a text file(rather large). What I need to do is remove all blank spaces in the columns preceding its data as well. Because of the blank spaces in front of the data in the columns it is messing up the data types when importing to SQL or access.....code is not optimized here because I am trying different things to get it to work.......
The boss is hopping mad so please hurry.....
SR = New System.IO.StreamReader(System.IO.File.OpenRead("C:\jjk0661.txt.tmp")
SW = New System.IO.StreamWriter(System.IO.File.OpenWrite("C:\jjk0669.txt")
'SW.WriteLine("TRITEM" & vbTab & vbTab & "TRDATE" & vbTab & vbTab & "POINV" & vbTab & "REF" & vbTab & "ACTION" & vbTab & "CUSTNO" & vbTab & "CUSTNAME" & vbTab & vbTab & vbTab & "TRCOST" & vbTab & "ONHAND" & vbTab & "INTRAN" & vbTab & "TRAFTER"
Dim strL As String
Do Until SR.Peek = -1
strL = SR.ReadLine
If strL.Trim = "" Then
'Skips the line if no text
Else
'strL.Format("{0}Column 1{0}Column 2{0}Column 3{0}Column 4{0}Column 5{0}Column 6{0}Column 7{0}Column 8{0}Column 9{0}Column 10{0}Column 11{0}", ControlChars.Tab, ControlChars.CrLf)
SW.WriteLine(strL)
End If
Loop
'System.IO.File.Delete(strFile)
'System.IO.File.Move(strFile & ".tmp", strFile)
SR.Close()
SW.Close()
The boss is hopping mad so please hurry.....
SR = New System.IO.StreamReader(System.IO.File.OpenRead("C:\jjk0661.txt.tmp")
SW = New System.IO.StreamWriter(System.IO.File.OpenWrite("C:\jjk0669.txt")
'SW.WriteLine("TRITEM" & vbTab & vbTab & "TRDATE" & vbTab & vbTab & "POINV" & vbTab & "REF" & vbTab & "ACTION" & vbTab & "CUSTNO" & vbTab & "CUSTNAME" & vbTab & vbTab & vbTab & "TRCOST" & vbTab & "ONHAND" & vbTab & "INTRAN" & vbTab & "TRAFTER"
Dim strL As String
Do Until SR.Peek = -1
strL = SR.ReadLine
If strL.Trim = "" Then
'Skips the line if no text
Else
'strL.Format("{0}Column 1{0}Column 2{0}Column 3{0}Column 4{0}Column 5{0}Column 6{0}Column 7{0}Column 8{0}Column 9{0}Column 10{0}Column 11{0}", ControlChars.Tab, ControlChars.CrLf)
SW.WriteLine(strL)
End If
Loop
'System.IO.File.Delete(strFile)
'System.IO.File.Move(strFile & ".tmp", strFile)
SR.Close()
SW.Close()