advanced parsing

    Date: 03/17/05 (Computer Help)    Keywords: rss

    If you are bored, perhaps you can help me with this problem, its for someone on a forum I go on...



    The file is formatted like this

    1 crux
    The problem that is the hardest to solve
    The crux shadows
    2 addendum
    An addition
    Addendum for those who submit combos
    3 groggy
    Half asleep and crabby
    I’m groggy still
    4 crabby
    Grumpy
    Being half asleep and crabby

    (the number doesnt matter really, because that can be added in later)

    And I need to get it like this

    crux, The problem that is the hardest to solve, The crux shadows
    addendum, an addition, Addendum...
    groggy, ....

    so basically it can be read into excel as a csv file.
    So far I have it like this:

    crux,
    The problem that is the hardest to solve,
    The crux shadows,

    addendum,
    An addition,
    Addendum for those who submit combos,

    groggy,
    Half asleep and crabby,
    I’m groggy still,

    (those are commas at the ends of the lines, although they look like periods/full stops)
    ....

    so basically i need to join up all lines with a comma at the end... any ideas??

    My script reads like this so far:

    cat words.txt |
    sed 's/$/\,/g' | #adds commas to end of each line
    tr -d '1''2''3''4''5''6''7''8''9''0' | #removes all numbers
    sed 'n;n;G;' > words.csv #adds a new line every forth line


    #sed -e :a -e '/\\$/N; s/\\\n//; ta' #should join up all lines with BACKSLASHES at the end

    How can I modify the last line to make it join up lines ending in the commas?

    Source: http://www.livejournal.com/community/computer_help/356807.html

« New AIM virus or whatever || qod »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home