New data to the first line in *.csv file via VB Script
Hello.
Welcome every one.
I have some data in CSV
I need to open this CSV file via VBS script and add some data in the end of first line and save this file. For example
aaa;bbb;ccc
111;111;111
222;222;222
should be:
aaa;bbb;ccc;ddd;eee;fff
111;111;111
222;222;222
Hot to do it with VBS ?
Best Regards
C
Re: New data to the first line in *.csv file via VB Script
Can you try the below code and see if that will work:
Code:
Set outputFile = fso.OpenTextFile(File1, ForWriting, True)
Set inputFile = fso.OpenTextFile(File2, ForReading)
Do While inputFile.AtEndOfStream <> True
arr = Split(inputFile.ReadLine, ",")
arr(3) = "E"
outputString = Join(arr, ",")
outputFile.WriteLine outputString
Loop
Re: New data to the first line in *.csv file via VB Script
Quote:
Originally Posted by
janos™
Can you try the below code and see if that will work:
Code:
Set outputFile = fso.OpenTextFile(File1, ForWriting, True)
Set inputFile = fso.OpenTextFile(File2, ForReading)
Do While inputFile.AtEndOfStream <> True
arr = Split(inputFile.ReadLine, ",")
arr(3) = "E"
outputString = Join(arr, ",")
outputFile.WriteLine outputString
Loop
Thank you.
I'll check this.