Link to home
Start Free TrialLog in
Avatar of zzwin
zzwin

asked on

How to append in the txt lines?

I have a big data.txt where lines look
50,70,3,30
85,15,30,5
75,7,90,77
etc
without blank lines. I would like to add  ,50,75,55 at the end of data in every single line so it looks
50,70,3,30,50,75,55
85,15,30,5,50,75,55
75,7,90,77,50,75,55

Any help with this?
ASKER CERTIFIED SOLUTION
Avatar of mkhaleelr
mkhaleelr

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of zzwin
zzwin

ASKER

Is there any way where temp.text  wiil be opened for both input and output, instead of making new temp1.txt file ?  
Avatar of zzwin

ASKER

Actually, for not extremely big files this solution is quite OK.
Thanx guys.
Here is another approach for smaller files:

Private Sub Command1_Click()
    Dim ff As Long
    Dim line As Variant
    Dim lines As New Collection
    Dim fileName As String
   
    fileName = "c:\Output.txt"
    If Dir(fileName) <> "" Then
            ff = FreeFile()
        Open fileName For Input As #ff
        Do While Not EOF(ff)
            Line Input #ff, line
            lines.Add line & ",50,75,55"
        Loop
        Close #ff
   
        ff = FreeFile()
        Open fileName For Output As #ff
        For Each line In lines
            Print #ff, line
        Next
        Close #ff
       
        MsgBox "Done"
    Else
        MsgBox fileName, vbCritical, "File Not Found"
    End If
End Sub