Results 1 to 9 of 9

Thread: copy from one csv file to another

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2008
    Posts
    64

    copy from one csv file to another

    Hello everyone,

    I was wondering if anyone could suggest a way to copy data from one csv file to another csv file.

    Basically I need to copy a column of numbers from one csv file to a second column position of another csv file.

    Is there an easy way to code this ?

    Thanks for any suggestion !

    cheers!

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,423

    Re: copy from one csv file to another

    do both csv files have the same number of lines?
    you want to copy 1 column's value in row1 of the first file to the 2nd column in row2 of the second file (etc.)?

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Sep 2008
    Posts
    64

    Re: copy from one csv file to another

    Hi Paul,

    yes, you are correct for both: the cvs files have the same number of lines and I want to copy file 1 column's value in in row 1 to a row1 of the 2nd column of the file 2, etc.

    As an additional thing, if I may ad, I also need to ad a header at the top of the both columns of the file 2.

    Thanks!

  4. #4
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,423

    Re: copy from one csv file to another

    heres an example:

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Sep 2008
    Posts
    64

    Re: copy from one csv file to another

    Paul,

    you're a champ, it works perfectly with all my files.
    Thank you very much for your help !

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Sep 2008
    Posts
    64

    Re: copy from one csv file to another

    Paul,

    one more thing: the Excel file remains open after I run the code, how do you close it ?

    THANKS!

  7. #7
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,423

    Re: copy from one csv file to another

    what excel file?
    do you mean output.txt?
    if thats it remove the process.start line

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Sep 2008
    Posts
    64

    Re: copy from one csv file to another

    Yes, the output.txt, I renamed it to .csv file and it opens in Excel.
    So, if I remove the process.start, what does the process.start do, I don't need it ?

    Thanks!

  9. #9
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,423

    Re: copy from one csv file to another

    i put the process.start line in there to show you the finished output.
    it opens output.txt (or whatever you renamed it as) in its default application. its not a necessary part of the program.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width