## Median calculator based on id match

Median calculator based on id match
# 8
03-20-2014
Quote:
Originally Posted by Corona688
I don't see anything in your input or output that looks remotely like a median. I don't understand.
By definition, if there are an odd number of elements in a list, the median is the middle element in the (sorted) list. (So for dog, with the values in the 3rd field being 0, 3, and 4; 3 is the median.) If there are an even number of elements in a list, the median is the average of the middle two elements of the list. (So for cat, with the values in the 3rd field being 2 and 6, 4 is the median.)
This User Gave Thanks to Don Cragun For This Post:
 Don Cragun View Public Profile for Don Cragun Find all posts by Don Cragun
# 9
03-20-2014
OK, so the median is based on data we don't see, and we just pick the middle without regard to any order but the given one. But I still don't understand.

4 makes sense for cat, being (2+6)/2, but how does one get 3 for dog? That's the last element, not the middle. I wondered if maybe they were line numbers instead, but that doesn't make sense either.
 Corona688 View Public Profile for Corona688 Visit Corona688's homepage! Find all posts by Corona688
# 10
03-20-2014
Quote:
Originally Posted by Corona688
OK, so the median is based on data we don't see, and we just pick the middle without regard to any order but the given one. But I still don't understand.

4 makes sense for cat, being (2+6)/2, but how does one get 3 for dog? That's the last element, not the middle. I wondered if maybe they were line numbers instead, but that doesn't make sense either.
The median is the middle element of the list after that list has been sorted.
 Don Cragun View Public Profile for Don Cragun Find all posts by Don Cragun

## Data match 2 files based on first 2 columns matching only and join if match

Hi, i have 2 files , the data i need to match is in masterfile and i need to pull out column 3 from master if column 1 and 2 match and output entire row to new file I have tried with join and awk and i keep getting blank outputs or same file is there an easier way than what i am...

## awk to update file based on partial match in field1 and exact match in field2

I am trying to create a cronjob that will run on startup that will look at a list.txt file to see if there is a later version of a database using database.txt as the source. The matching lines are written to output. \$1 in database.txt will be in list.txt as a partial match. \$2 of database.txt...

## Merge lines based on match

I am trying to merge two lines to one based on some matching condition. The file is as follows: Matches filter: 'request ', timestamp, <HTTPFlow request=<GET: Matches filter: 'request ', timestamp, <HTTPFlow request=<GET: Matches filter: 'request ', timestamp, <HTTPFlow ...

## Match based on criteria to file

Trying to match \$1 of target.txt to \$5 of file.txt. If there is a match then in an output.txt file \$1,\$1 (row underneath),\$6,\$4,\$7 from file.txt are printed on the same line as \$1 of target.txt. The input is from excel and the output should be tab-deliminated. Thank you :). target.txt...

## New files based off match or no match

Trying to match \$2 in original_targets with \$2 of new_targets . If the two numbers match exactly then a match.txt file is outputted using the information in the new_targets in the beginning 4 fields \$1, \$2, \$3, \$4 and value of \$4 in the original_targets . If there is "No Match" then a no...

## Match and print based on columns

HI, I have 2 different questions in this thread. Consider 2 files as input (input file have different line count ) File 1 1 1 625 56 1 12 657 34 1 9 25 45 1 2 20 54 67 3 25 35 27 4 45 73 36 5 125 56 45 File2 1 1 878 76 1 9 83 67 2 20 73 78 4 47 22 17 3 25 67 99

## Match files based on either of the two columns awk

Dear Shell experts, I have 2 files with structure: File 1: ID and count head test_GI_count1.txt 1000094 2 10039307 1 10039641 1 10047177 11 10047359 1 1008555 2 10120302 1 10120672 13 10121776 1 10121865 32 And 2nd file: head Protein_gi_GeneID_symbol.txt protein_gi GeneID...

## Display/Cut the characters based on match

I have input file like this update tablename set column1='ABC',column2='BBC' where columnx=1 and columny=100 and columnz='10000001' update tablename set column1='ABC',column2='BBC',column3='CBC' where columnx=1 and columny=100 and columnz='10000002' update tablename set column1='ABC' where...

## Awk based script to find the median of all individual columns in a data file

Hi All, I have some data like below. Step1,Param1,Param2,Param3 1,2,3,4 2,3,4,5 2,4,5,6 3,0,1,2 3,0,0,0 3,2,1,3 ........ so on Where I need to find the median(arithmetic) of each column from Param1...to..Param3 for each set of Step1 values. (Sort each specific column, if the...

## Split a record based on particular match

Hi , I have a requirement to split the record based on particular match using UNIX. Case1: Input Record : 10.44.48.63;"Personals/Dating;sports";1441 Output Records : 10.44.48.63;Personals/Dating;1441;Original 10.44.48.63;sports;1441;Dummy Case2: Input Record : ...