Partially match and rank question


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Partially match and rank question
# 8  
Old 09-26-2014
Absolutely! It's so frustrating to produce sth and then find out its useless 'cause its based on wrong information.
# 9  
Old 09-26-2014
Quote:
Originally Posted by Don Cragun
This is a result of what is known in the trade as GIGO (garbage in, garbage out). You told us what your input files looked like and you told us what you wanted your output to look like based on those input formats. We provided you code that performed the requested transformations and gave the exact output you said you wanted based on those input file formats.

Now you show us an input file format that is completely different from your sample input file format for file1 and tell us that our suggestions didn't work. Our software isn't smart enough to magically realize that the input format for file1 was totally wrong and transform itself into new code that can handle your new input file format.

Next time please give us representative sample data instead of wasting the time of all of the volunteers who were trying to help you. Smilie

I have other things to do this afternoon, but I may be able to try to put something together later to work with your new input input file format.
Hi Don,

I feel very sorry make you frustrated. I just want to gave you guys simpler example files to deal with it and I thought it will apply to my own data, that's why I gave you the first example files which mislead you. I didn't realized that the situation can be very different actually. Next time I will be more straightforward and won't waste your time. I really appreciate your answer and your kindness. Thank you.

---------- Post updated at 10:55 AM ---------- Previous update was at 10:54 AM ----------

Quote:
Originally Posted by RudiC
Absolutely! It's so frustrating to produce sth and then find out its useless 'cause its based on wrong information.
Hi RudiC,

I feel very sorry make you frustrated. I just want to gave you guys simpler example files to deal with it and I thought it will apply to my own data, that's why I gave you the first example files which mislead you. I didn't realized that the situation can be very different actually. Next time I will be more straightforward and won't waste your time. I really appreciate your answer and your kindness. Thank you.

---------- Post updated at 10:56 AM ---------- Previous update was at 10:55 AM ----------

Quote:
Originally Posted by Don Cragun
With your new input file format, the following seems to work:
Code:
awk '
FNR == NR {
        key[$1]
        next
}
{       for(k in key)
                if(index($2, k)) 
                        key[k] += $4
}
END {   for(k in key)
                printf("%s (%.1f)\n", k, key[k]) 
}' file2 file1 | sort -t'(' -k2,2n

Don,

Your script works perfectly. Thank you so much and it is a big help.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Match and rank question

I actually posted a similar question before but my expression probably lead the helper here frustrated. I also tried to figure it out by myself but failed. So I rephrase my question again and hopefully it is clearer to understand. I really appreciate your help. Here is the file1target:... (2 Replies)
Discussion started by: yuejian
2 Replies

2. UNIX for Dummies Questions & Answers

Exact match question

Hi guys, I am using Centos 6.3. Actually I posted similar question but I still have some minor problem need be fixed. I have two files, file1:target: gi|57529786|ref|NM_001006513.1| mfe: -31.4 kcal/mol p-value: 0.006985 target: gi|403048743|ref|NM_001271159.1| mfe: -29.6 kcal/mol p-value:... (11 Replies)
Discussion started by: yuejian
11 Replies

3. UNIX for Dummies Questions & Answers

Script partially executes??

Hi All, I am calling a shell script from another shell script, however, it only executes part of it (the echo commands only). What could be some causes for that? For example: ShellScriptA.sh: ... ... ... . ShellScriptB.sh ShellScriptB.sh contents: echo date echo... (7 Replies)
Discussion started by: DBnixUser
7 Replies

4. Shell Programming and Scripting

How to output the partially equals

Hello i have 2 files: a.out 10.1.1.1 james.franco 10.1.1.3 google.gol 10.1.1.14 yahoo.bol b.out 10.1.1.1 10.1.1.3 10.1.1.45 I need to see an output just with: 10.1.1.1 james.franco 10.1.1.3 google.gol Thankz in advance!! (2 Replies)
Discussion started by: danielldf
2 Replies

5. Web Development

Fix For Google Page Rank: Wordpress List Rank Dashboard Widget

Here is the fix for the recent Google changes to their pagerank API. For example, in the List Rank Dashboard Widget Wordpress Plugin (Version 1.7), in this plugin file: list-rank-dashboard-widget/wp-list-rank-class.php in this function: function getGooglePR($url) Change this line: ... (0 Replies)
Discussion started by: Neo
0 Replies

6. Shell Programming and Scripting

Is it possible to partially clear the terminal?

The clear command specifically says it can only clear the entire terminal display. There are no arguments. So I'm wondering if there are any work arounds. Carriage return does not work for this as it only moves the cursor to the beginning of the line we're on. And obviously NL only goes down. If... (1 Reply)
Discussion started by: FunkyLich
1 Replies

7. Shell Programming and Scripting

Exact match question

Hi, I have a file like follows . . . White.Jack.is.going.home Black.Jack.is.going.home Red.Jack.is.going.home Jack.is.going.home . . . when I make: cat <file> | grep -w "Jack.is.going.home" it gives: White.Jack.is.going.home Black.Jack.is.going.home Red.Jack.is.going.home... (4 Replies)
Discussion started by: salih81
4 Replies

8. Shell Programming and Scripting

pattern match question

I have a pattern match problem I could use your help with I have a file in the following format (names.txt) jae,doe john,doe jay,doe I need to loop through the file using FOR and check the names in names.txt against another file (information.txt). information.txt is in the following... (2 Replies)
Discussion started by: chaos40
2 Replies

9. Shell Programming and Scripting

How to partially replace variable value?

I have variable $2 whose value is expdp_SDW_MSTR_VMDB.par I want to replace three characters from right (par) with (log) Input --> expdp_SDW_MSTR_VMDB.par Output --> expdp_SDW_MSTR_VMDB.log Thanks Deep (2 Replies)
Discussion started by: deep.singh
2 Replies

10. UNIX for Dummies Questions & Answers

grep question - match a url

I'm trying to find files which have urls such as "services/amf/fri/home.html" and "services/amj/fri/air.html" - so the pattern I want to match with grep, logically, is one that has 1. "services/" 2. stuff in between including slashes, numbers, underscores etc 3. ending in "html" Can... (5 Replies)
Discussion started by: pauljohn
5 Replies
Login or Register to Ask a Question