Find the answer to your Linux question:
Results 1 to 3 of 3
hello all, I tried for 10 hours to find a solution to this problem but I have to ask for help. I have a script that extracts some information from ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Oct 2012
    Posts
    2

    How to convert a text file in a csv file


    hello all,
    I tried for 10 hours to find a solution to this problem but I have to ask for help. I have a script that extracts some information from an email. this is the output

    output.txt

    username = sevenofnine
    firstname = Annika
    lastname = Hansen
    comments = borg
    password = 0000


    I need to convert this file to a csv file like this

    sevenofnine,Annika,Hansen,borg,0000

  2. #2
    drl
    drl is offline
    Linux Engineer drl's Avatar
    Join Date
    Apr 2006
    Location
    Saint Paul, MN, USA / CentOS, Debian, Slackware, {Free, Open, Net}BSD, Solaris
    Posts
    1,286
    Hi.

    Suppose your (originally posted) data is on file data1. Then:
    Code:
    cut -f3 -d" " data1 |
    paste -d, -s
    produces:
    Code:
    someusername,somename,somelastname,somecomments,somepassword
    Best wishes ... cheers, drl
    Welcome - get the most out of the forum by reading forum basics and guidelines: click here.
    90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
    We look forward to helping you with the challenge of the other 10%.
    ( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )

  3. #3
    Just Joined!
    Join Date
    Oct 2012
    Posts
    2
    I can not believe it! you're the best!

Posting Permissions

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