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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

text file format

Status
Not open for further replies.

UKmedia

Programmer
Nov 2, 2002
90
Evening All,

Does anyone have any idea on how I can format a txt file that is already populated with text.

The file comes as:

ICR,Z1,50,1,14:55:07,15/10/2008
28,10.00,459.00
29,14.00,459.00
30,16.00,512.00

and I want it to just be one line

ICR,Z1,50,1,14:55:07,15/10/2008
28,10.00,459.00,29,14.00,459.00,30,16.00,512.00

cheers in advance

UKmedia productions
 
1: Open the file with a streamreader
2: Use the "readline" method to read each line and concatenate to a single line
3: Use a stringwriter object to write back out to the text file.

The sample in this link should be enough to get you started (not exactly what you want, but all the parts are there).

 
I have found this that allows me to read the file and I am outputting the response to a textbox but I have 1 question

How can I ignore the first row as I don't want to read that row?


Code:
Using MyReader As New  _
            Microsoft.VisualBasic.FileIO.TextFieldParser("C:\test\file50_old.txt")
            MyReader.TextFieldType = FileIO.FieldType.Delimited
            MyReader.SetDelimiters(",")
            Dim currentRow As String()
            While Not MyReader.EndOfData
                Try
                    currentRow = MyReader.ReadFields()
                    Dim currentField As String
                    For Each currentField In currentRow
                        'MsgBox(currentField)
                        TextBox1.AppendText(currentField & ",")
                    Next
                Catch ex As Microsoft.VisualBasic.FileIO.MalformedLineException
                    MsgBox("Line " & ex.Message & _
                    "is not valid and will be skipped.")
                End Try
            End While
        End Using

UKmedia productions
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top