CSV formate file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ajd335
    New Member
    • Apr 2008
    • 123

    #1

    CSV formate file

    Hi .
    I dont know in which thread my question should be appropriate , so sorry for that.
    I have one data base table , and i am importing all the results of one "email " field into result.txt ,which is in my home directory in unix server..

    Now i want that file to be comma seperated,
    means all the email should be

    like

    abc@yahoo.com
    bbb@gmail.com
    ddd@hotmail.com

    something like this..Can u please help me ??

    +---------------+
    | email |
    +---------------+
    | |
    | |
    | |
    | |
    | abc@yahoo.com |
    | email |
    +---------------+
  • gpraghuram
    Recognized Expert Top Contributor
    • Mar 2007
    • 1275

    #2
    Originally posted by ajd335
    Hi .
    I dont know in which thread my question should be appropriate , so sorry for that.
    I have one data base table , and i am importing all the results of one "email " field into result.txt ,which is in my home directory in unix server..

    Now i want that file to be comma seperated,
    means all the email should be

    like

    abc@yahoo.com
    bbb@gmail.com
    ddd@hotmail.com

    something like this..Can u please help me ??

    +---------------+
    | email |
    +---------------+
    | |
    | |
    | |
    | |
    | abc@yahoo.com |
    | email |
    +---------------+

    You want the sql statement output should be formatted like the above or you want to format the contents in a file like the above?

    Raghu

    Comment

    • ajd335
      New Member
      • Apr 2008
      • 123

      #3
      Originally posted by gpraghuram
      You want the sql statement output should be formatted like the above or you want to format the contents in a file like the above?

      Raghu
      Hi Raghu,
      The above output is (result.txt) what I am getting after all the manipulation.
      Now i am creating one more file i.e final.txt in which i just want

      abc@gmail.com
      ddd@yahoo.com


      something like that

      Comment

      • gpraghuram
        Recognized Expert Top Contributor
        • Mar 2007
        • 1275

        #4
        Originally posted by ajd335
        Hi Raghu,
        The above output is (result.txt) what I am getting after all the manipulation.
        Now i am creating one more file i.e final.txt in which i just want

        abc@gmail.com
        ddd@yahoo.com


        something like that
        What i understood is you want to convert a newline separated email id's to a comma separated email id's.
        If yes the you can do it as

        Code:
        cat "ip.txt" | tr '\n' ',' > op.txt
        Raghuram

        Comment

        Working...