Ciao guys, I'm trying to solve a problem with some text I have. I have processed two text files and now I have something like this:

| wordF1 | percentageF1 | wordF2 | percentageF2 | |------------+--------------+--------------+--------------| | politici | 0.0489 | politici | 0.0295 | | referendum | 0.0238 | consenso | 0.0126 | | verità | 0.0198 | referendum | 0.00654 | | scandalo | 0.0112 | verità | 0.00526 | | vergogna | 0.00723 | tradizionali | 0.00343 | | corrotto | 0.00439 | tradizione | 0.00266 | | scandali | 0.00394 | tradizioni | 0.00234 | | consenso | 0.00373 | tradizionale | 0.0022 | | corrotti | 0.00332 | scandalo | 0.00142 | | propaganda | 0.0027 | vergogna | 0.00131 | |------------+--------------+--------------+--------------|

What I am trying to do is to align the words (so I understand I should do some string compairison but then I don't know how) by keeping file1 as reference: this means that if a word is present in file1 but not in file2 then the whole raw should be deleted. Once this is done I would like to compute the differences of the percentages (f1-f2).

At the end I would like something like this:

| wordF1 | wordF2 | difference | |------------+------------+------------| | politici | politici | +0.5 | | referendum | referendum | +0.126 | | verità | verità | +0.006 | | ... | ... | ... | |------------+------------+------------|

I was trying to do this in awk but after a lot of tryings I gave up. If somebody could help I'd be very happy.

One of Crete's own prophets has said it: 'Cretans are always liars, evil brutes, lazy gluttons'.
He has surely told the truth.


In reply to Aligning text and then perfom calculations by epimenidecretese

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.