Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Compare Values between column in the same file Post 302982398 by Nina2910 on Wednesday 28th of September 2016 03:06:31 PM
Old 09-28-2016
@Ravinder your code is partially satisfying the expectation.
I am stating the conditions again on which code will decide GOOD or WARNING for Single character Values of column 3 (A, C, E, M, N, P, S).
Code:
if Column 3 has value= E then check column 7,9,10,11,12,13 (values should be zero in each) and hence sum of these columns should be zero.
if Column 3 has value= S then check column 8,9,10,11,12,13 (values should be zero in each) and hence sum of these columns should be zero.
if Column 3 has value= A then check column 7,8,10,11,12,13 (values should be zero in each) and hence sum of these columns should be zero.
if Column 3 has value= M then check column 7,8,9,11,12,13 (values should be zero in each) and hence sum of these columns should be zero.
if Column 3 has value= P then check column 7,8,9,10,11,13 (values should be zero in each) and hence sum of these columns should be zero.
if Column 3 has value= N then check column 7,8,9,10,12,13 (values should be zero in each) and hence sum of these columns should be zero.
if Column 3 has value= C then check column 7,8,9,10,11,12 (values should be zero in each) and hence sum of these columns should be zero.

as column 3 can be any of these Values A, C, E, M, N, P, S or combinations of these characters eg. AS,SE,MP,PS,SAE,EAM, CEPS and more.The code should be able to Calculate the values based on Dynamic combinations.

for the combination, code should check only common columns for all single character in combination.
example 1-
if Column 3 has value= E then check column 7,9,10,11,12,13 (values should be zero in each) and hence sum of these columns should be zero.
if Column 3 has value= S then check column 8,9,10,11,12,13 (values should be zero in each) and hence sum of these columns should be zero.
so if it is ES or SE, then code should check common columns which in this case are 9,10,11,12,13 and sum of these should zero.
example 2-
if Column 3 has value= S then check column 8,9,10,11,12,13 (values should be zero in each) and hence sum of these columns should be zero.
if Column 3 has value= A then check column 7,8,10,11,12,13 (values should be zero in each) and hence sum of these columns should be zero.
if Column 3 has value= E then check column 7,9,10,11,12,13 (values should be zero in each) and hence sum of these columns should be zero.
so if column 3 Value is SAE, EAS,ASE, then code should check common columns which in this case are 10,11,12,13 and sum of these should zero.

---------- Post updated at 03:06 PM ---------- Previous update was at 02:54 PM ----------

@Rudi ...row 3,4,6 should have "WARNING" in the output file. I have fixed the my output file in post #1.

Last edited by Nina2910; 09-28-2016 at 09:00 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

I need to extract last column of a file and compare the values

Hi, I am new to unix and I need help in solving below mentioned issue, really appreciate ur help. I have a file sam, john, 2324, 07142007 tom, thomson, 2343, 07142007 john, scott, 2478, 07142007 its a comma delimited file, I need to extract the last column from each line and this... (4 Replies)
Discussion started by: vukkusila
4 Replies

2. UNIX for Advanced & Expert Users

Compare two files using awk or sed, add values in a column if their previous fields are same

Hi All, I have two files file1: abc,def,ghi,5,jkl,mno pqr,stu,ghi,10,vwx,xyz cba,ust,ihg,4,cdu,oqw file2: ravi,def,kishore ramu,ust,krishna joseph,stu,mike I need two output files as follows In my above example, each row in file1 has 6 fields and each row in file2 has 3... (1 Reply)
Discussion started by: yerruhari
1 Replies

3. UNIX for Dummies Questions & Answers

Compare two files using awk or sed, add values in a column if their previous fields are same

Hi All, I have two files file1: abc,def,ghi,5,jkl,mno pqr,stu,ghi,10,vwx,xyz cba,ust,ihg,4,cdu,oqw file2: ravi,def,kishore ramu,ust,krishna joseph,stu,mike I need two output files as follows In my above example, each row in file1 has 6 fields and each row in file2 has 3... (1 Reply)
Discussion started by: yerruhari
1 Replies

4. Shell Programming and Scripting

How to compare the values of a column in awk in a same file and consecutive lines..

I would like to compare the values of 2nd column of consecutive lines of same file in such a way so that if the difference between first value and second value is more than 100 it should print complete line else ignore line. Input File ========== PDB 2500 RTDB 123 RTDB-EAGLE 122 VSCCP 2565... (4 Replies)
Discussion started by: manuswami
4 Replies

5. Shell Programming and Scripting

Take values from a column and put it in a variable and compare

Hi, I have a table in unix from which i want to read the contents line by line, then filter out the values from 6th column one by one and compare it a fixed value. How to do this? (7 Replies)
Discussion started by: arijitsaha
7 Replies

6. Shell Programming and Scripting

Compare values in two files. For matching rows print corresponding values from File 1 in File2.

- I have two files (File 1 and File 2) and the contents of the files are mentioned below. - I am trying to compare the values of Column1 of File1 with Column1 of File2. If a match is found, print the corresponding value from Column2 of File1 in Column5 of File2. - I tried to modify and use... (10 Replies)
Discussion started by: Santoshbn
10 Replies

7. UNIX for Dummies Questions & Answers

Compare values of fields from same column with awk

Hi all ! If there is only one single value in a column (e.g. column 1 below), then return this value in the same output column. If there are several values in the same column (e.g. column 2 below), then return the different values separated by "," in the output. pipe-separated input: ... (11 Replies)
Discussion started by: lucasvs
11 Replies

8. Shell Programming and Scripting

How to compare the values of a column in a same file using awk?

Dear Unix experts, I have got a file where I would like to compare the values of second column if first column is same in such a way that the difference between the values is >50. If not, I would like to discard both values. For example, my input file looks like - comp275_c0_seq2 73... (7 Replies)
Discussion started by: utritala
7 Replies

9. Shell Programming and Scripting

Compare two files column values using awk

Judi # cat File1 judi /export/home 76 judi /usr 83 judi # judi # cat File2 judi /export/home 79 judi /usr 82 judi # if COLUMN3 of File2 is greater that COLUMN3 of File1, then print File2's lines juid /export/home 79 Code tags please (2 Replies)
Discussion started by: judi
2 Replies

10. UNIX for Beginners Questions & Answers

Compare values in multiple rows in one column using awk

I would like to compare values in column 8, and grep the ones where the different is > 1, columns 1 and 2 are the key for array. Every 4 rows the records values in columns 1 and 2 changed. Then, the comparison in the column 8 need to be done for the 4 rows everytime columns 1 and 2 changed ... (4 Replies)
Discussion started by: jiam912
4 Replies
Alzabo::Index(3pm)					User Contributed Perl Documentation					Alzabo::Index(3pm)

NAME
Alzabo::Index - Index objects SYNOPSIS
foreach my $i ($table->indexes) { foreach my $c ($i->columns) { print $c->name; print '(' . $i->prefix($c) . ')' if $i->prefix($c); } } DESCRIPTION
This object represents an index on a table. Indexes consist of columns and optional prefixes for each column. The prefix specifies how many characters of the columns should be indexes (the first X chars). Some RDBMS's do not have a concept of index prefixes. Not all col- umn types are likely to allow prefixes though this depends on the RDBMS. The order of the columns is significant. METHODS
columns Returns an ordered list of the "Alzabo::Column" objects that are being indexed. prefix ("Alzabo::Column" object) A column prefix is, to the best of my knowledge, a MySQL specific concept, and as such cannot be set when using an RDBMSRules module for a different RDBMS. However, it is important enough for MySQL to have the functionality be present. It allows you to specify that the index should only look at a certain portion of a field (the first N characters). This prefix is required to index any sort of BLOB column in MySQL. This method returns the prefix for the column in the index. If there is no prefix for this column in the index, then it returns undef. unique Returns a boolean value indicating whether the index is a unique index. fulltext Returns a boolean value indicating whether the index is a fulltext index. function For function indexes, this returns the function being indexed. id The id is generated from the table, column and prefix information for the index. This is useful as a canonical name for a hash key, for example. Returns a string that is the id which uniquely identifies the index in this schema. table Returns the "Alzabo::Table" object to which the index belongs. AUTHOR
Dave Rolsky, <autarch@urth.org> perl v5.8.8 2007-12-23 Alzabo::Index(3pm)
All times are GMT -4. The time now is 09:52 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy