Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Urgent Problem Text File Problem......

Status
Not open for further replies.
Jan 14, 2003
7
0
0
US
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()
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top