fanticla has asked for the wisdom of the Perl Monks concerning the following question:
Hi monks
My problem should be easy to solve, but I am still struggling very much to find a proper solution to it.
I have two txt fils containing two lists of words - one word per line - with a score (the score simply being the row number). I'd like to merge the two files, ordering the words according with a new ranking computed by multiplying the scores of the same word in the two files.
The files have the following format:
FILE 1 hello 1 today 2 well 3 yes 4
FILE 2 hello 1 yes 2 today 3 well 4
The output should look like:
hello 1 today 6 yes 8 well 12
I am by now reading FILE 1 line by line, reading through FILE 2 to match the same word, multiplying the scores and write the result out into a new file. As the list are huge, it seems to me a very BAD way to do this task. Any idea how I could do it better? Sorry if my question is too simple...
Thanks, Cla
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Merging two list with simple operation
by Corion (Patriarch) on Jul 31, 2010 at 17:57 UTC | |
by fanticla (Scribe) on Jul 31, 2010 at 18:32 UTC | |
|
Re: Merging two list with simple operation
by BrowserUk (Patriarch) on Jul 31, 2010 at 18:11 UTC | |
by fanticla (Scribe) on Jul 31, 2010 at 18:31 UTC | |
by BrowserUk (Patriarch) on Jul 31, 2010 at 19:04 UTC | |
by fanticla (Scribe) on Aug 01, 2010 at 07:26 UTC | |
|
Re: Merging two list with simple operation
by ahmad (Hermit) on Jul 31, 2010 at 18:48 UTC | |
by fanticla (Scribe) on Jul 31, 2010 at 19:08 UTC | |
by rir (Vicar) on Aug 04, 2010 at 21:01 UTC | |
|
Re: Merging two list with simple operation
by kikuchiyo (Hermit) on Aug 01, 2010 at 19:18 UTC |