To compare first two columns in an excel file


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers To compare first two columns in an excel file
# 1  
Old 06-28-2011
To compare first two columns in an excel file

Hi All,

i have a excel sheet with two columns as below.

column1 column2
100 100
200 300
300 400
400 400
500 600

i need to compare the values these two columns and the output should be printed in the third column...if these values are equal the output should be green and if these vlues are not equal output value should be red.. please see the output format below..

column1 column2 column3
100 100 green
200 300 red
300 400 red
400 400 green
500 600 red

please help me in writing a unix code for the above requirement...

Thanks in advance.
Arun ManasSmilie
# 2  
Old 06-28-2011
Try if this awk fills your requirement (can be shorter probably Smilie )
Code:
awk '{if ($1==$2) print $0 FS "green"; else print $0 FS "red" } ' inputfile

# 3  
Old 06-28-2011
put your column1 values to A column in excel file
put your column2 values to B column in excel file

place the below formula in C1 and enter. After that drag the formula to end of your values in A and B column

Code:
 
=IF(COUNTIF(B:B,A1),"Green","Red")

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Reading specific range of columns in an Excel file

Hi All, I want to read an excel file. PFA excel, I want to read the cloumn from A to G and the V to AH starting from Row number 3. Please help me on this. (7 Replies)
Discussion started by: Abhisrajput
7 Replies

2. Shell Programming and Scripting

Need specific columns in a log file as excel.

Hi All... I am in need of few columns from a log file.. in .xls file... below is what i have tried. my log file has 16 colums with " ; " as delimiter, but i need randomn columns 1 2 3 4 5 6 10 11 16 in an excel. I tried to awk the columns with delimiter ; and it worked, below is the log... (5 Replies)
Discussion started by: nanz143
5 Replies

3. Shell Programming and Scripting

Compare two date columns in same file

Hi All, Need to compare two date columns from the filname FinalDate.txt. My data's are like below D_OT_START D_EXP_STR Amount 1/3/2012 1/3/2012 5000 6/21/2011 6/25/2011 6000 2/28/2011 2/28/2011 7000 7/16/2010 8/16/2010 8000 7/14/2010 10/26/2010 9000 ... (3 Replies)
Discussion started by: suresh_target
3 Replies

4. Shell Programming and Scripting

Compare Multiple Columns in one file

Hello guys, I am quite new to Shell Scripting and I need help for this I have a CSV file like this: Requisition,Order,RequisitionLineNumber,OrderLineNumber REQ1,Order1,1,1 REQ1,Order1,1,3 REQ2,Order2,1,5 Basically what I want to do is compare the first 3 fields If all 3 fields are the same... (5 Replies)
Discussion started by: jeffreybsu
5 Replies

5. UNIX for Dummies Questions & Answers

Search for string in a file then compare it with excel files entry

All, i have a file text.log: cover6 cover3 cover2 cover4 other file is abc.log as : 0 0 1 0 Then I have a excel file result.xls that contains: Name Path Pass cover2 cover3 cover6 cover4 (1 Reply)
Discussion started by: Anamika08
1 Replies

6. UNIX for Dummies Questions & Answers

How to delete columns with numbers in an excel file?

Dear all, I have one file (see below) with more then 100 columns and 2500 rows, and need only column which has GType in label with Alphabets, please help me to remove these columns with numbers. input file is n.201.GType n-201.Theta n-201.R n_1.GType n_1.Theta n_1.R... (6 Replies)
Discussion started by: AAWT
6 Replies

7. Shell Programming and Scripting

How to sort columns in excel(csv) file

i want sort columns with headers based on another file headers file1 eg: i'm having an empty file with only coumn names like lastname firstname title expirydate stlcno status etc... another file with same column names and some other as well but in different order... file2 eg:firstname... (2 Replies)
Discussion started by: Man83Nagesh
2 Replies

8. Shell Programming and Scripting

compare file columns

I need help in file comparision. I have two files in below format: FILE_A: ------- COL1 COL2 COL3 COL4 COL5 FILE_B: ------- COL1A COL1B COL1C COL1D COL1E i want to compare for a for each row in FILE_A and FILE_B COL1 of FILE_A with COL1B of FILE_B COL3 of FILE_A with COL1E of... (1 Reply)
Discussion started by: learnoutmore99
1 Replies

9. Shell Programming and Scripting

how to convert fields from a text file to excel columns

i have this file which has the following contents: ,-0.3000 ,-0.3000 ,-0.3000 ,-0.9000 ,-0.9000 ,-0.9000 i would like to get this: -0.3-0.9-0.3-0.9-0.3-0.9 so far i am trying: awk '{for(i=1; i<=NF; i++) {printf("%f\n",$i)}}' test1 > test2 any help... (4 Replies)
Discussion started by: npatwardhan
4 Replies

10. Shell Programming and Scripting

use awk to read randomly located columns in an excel file

Hi, I have an excel file that have a random count of columns/fields and what im trying to do is to only retrieve all the rows under 2 specific field headers. I can use the usually command for awk which is awk 'print{ $1 $2}' > output.txt, but the location of the 2 specific field headers is... (9 Replies)
Discussion started by: mdap
9 Replies
Login or Register to Ask a Question