1

I would like to read from the second line of a text file to write its data into a CSV file.

What is the best way of doing this?

Open InputFile For Input As #1  
Open OutputFile For Output As #2  
Do Until EOF(1)  
     Line Input #1, strData  
    'Read data from second line of text file and Write into CSV file  
    Print #2, strData  
Loop  
Close #1  
Close #2

1 Answer 1

2

Just read in the first line and discard it:

Sub Luxation()
    Dim InputFile As String, OutputFile As String, strData As String
    InputFile = "C:\TestFolder\File1.txt"
    OutputFile = "C:\TestFolder\xxxx.txt"
    Open InputFile For Input As #1
    Open OutputFile For Output As #2
    Line Input #1, strData
    Do Until EOF(1)
        Line Input #1, strData
        Print #2, strData
    Loop
    Close #1
    Close #2
End Sub
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .