Results 1 to 3 of 3

Thread: New data to the first line in *.csv file via VB Script

  1. #1
    Join Date
    Apr 2012
    Location
    Europe
    Posts
    7

    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

  2. #2
    Join Date
    Jan 2006
    Posts
    605

    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

  3. #3
    Join Date
    Apr 2012
    Location
    Europe
    Posts
    7

    Re: New data to the first line in *.csv file via VB Script

    Quote Originally Posted by janos™ View Post
    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.

Similar Threads

  1. Replies: 19
    Last Post: 17-11-2010, 04:19 PM
  2. Can't convert documents in Php script (via command line)
    By eawade in forum Windows Software
    Replies: 2
    Last Post: 20-01-2010, 06:34 AM
  3. How to let Java read text file line by line.
    By Visala28 in forum Software Development
    Replies: 3
    Last Post: 04-08-2009, 11:30 PM
  4. Script to insert new line in a file in linux
    By OSzilla in forum Operating Systems
    Replies: 3
    Last Post: 28-07-2009, 11:48 PM
  5. Bash Script, read without new line
    By Kieran in forum Software Development
    Replies: 2
    Last Post: 06-02-2009, 09:59 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,704,492.23169 seconds with 17 queries