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?
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Actually, for not extremely big files this solution is quite OK.
Thanx guys.
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
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
ASKER