04-27-2015
Hi All/Experts,
Let me put my requirement in short and precise, PFB my requirement and issue where I am stuck,
1. In the attached zip file, I want to read the csv files and in the csv files, I want to exclude Header and Trailer record.
2. After excluding Header and Trailer, In column D I want to calculate sum of all rows present under column D and check whether the sum matches with the value present in Trailer record/last record under the same Column D.
3. After doing a match with Trailer record, If the sum matches with trailer record, then simply echo "All Correct" else If the sum does not match with trailer record value under the same column, in our case Column D, then echo "Sum does not match" and exit with return code 16.
4. The entire same process defined in point 1,2,3 needs to be followed for column E,F,G,H,I,J,K,L,M,N,O also.
I hope now the above is clear. For this I have written some code but I don't know unix is behaving differently for each csv file. I execute my code for pf_20150127.csv file sum matches correctly with that of trailer record in the file, When I execute the same code for pf_20150325.csv file sum does not match with trailer record.
For pf_20150325.csv file, Unix is reading the trailer record value with decimal values like XXXXXXXX.00, and my sum I am calculating doesn't have any decimal values.
For pf_20150127.csv file, Unix is reading the trailer record with out decimal values which is quite not understandable to me.
Finally, I am confused and wanted to ask whether this kind of validation mentioned above in points 1,2,3,4 are possible to do in Unix shell scripting or Is there any other way of doing it. Please help me the solution that of shell script only.
With Regards,
TPK
---------- Post updated 04-27-15 at 04:49 AM ---------- Previous update was 04-26-15 at 10:48 PM ----------
Hi All,
Any Updates? Please help me out.
With Regards,
TPK
Last edited by tpk; 04-27-2015 at 12:56 AM..
Reason: Correction
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I have a file file like this. I want to sum all column 1 values.
input
A 2
A 3
A 4
B 4
B 2
Out put
A 9
B 6 (3 Replies)
Discussion started by: suresh3566
3 Replies
2. Shell Programming and Scripting
Hi All,
I have a file which is having 3 columns as (string string integer)
a b 1
x y 2
p k 5
y y 4
.....
.....
Question:
I want get the unique value of column 2 in a sorted way(on column 2) and the sum of the 3rd column of the corresponding rows. e.g the above file should return the... (6 Replies)
Discussion started by: amigarus
6 Replies
3. Shell Programming and Scripting
I have a file in the following layout:
201008005946873001846130058030701006131840000000000000000000
201008006784994001154259058033001009527844000000000000000000
201008007323067002418095058034801002418095000000000000000000
201008007697126001722141058029101002214158000000000000000000... (2 Replies)
Discussion started by: jclanc8
2 Replies
4. Shell Programming and Scripting
12-11-2012,PNL,158406
12-11-2012,RISK,4564
12-11-2012,VAR_1D,310101
12-11-2012,VAR_10D,310101
12-11-2012,CB,866
12-11-2012,STR_VAR_1D,298494
12-11-2012,STR_VAR_10D,309623
09-11-2012,PNL,1024106
09-11-2012,RISK,4565
09-11-2012,VAR_1D,317211
09-11-2012,VAR_10D,317211
09-11-2012,CB,985... (7 Replies)
Discussion started by: manas_ranjan
7 Replies
5. Shell Programming and Scripting
Hi,
My input files is like this
axis1 0 1 10
axis2 0 1 5
axis1 1 2 -4
axis2 2 3 -3
axis1 3 4 5
axis2 3 4 -1
axis1 4 5 -6
axis2 4 5 1
Now, these are my following tasks
1. Print a first column for every two rows that has the same value followed by a string.
2. Match on the... (3 Replies)
Discussion started by: jacobs.smith
3 Replies
6. Shell Programming and Scripting
Hi,
I have a table to be imported for R as matrix or data.frame but I first need to edit it because I've got several lines with the same identifier (1st column), so I want to sum the each column (2nd -nth) of each identifier (1st column)
The input is for example, after sorted:
K00001 1 1 4 3... (8 Replies)
Discussion started by: sargotrons
8 Replies
7. Shell Programming and Scripting
Hi,
i have log like below:
A 2 5
B 4 1
C 6 8
B 0 1
C 1 0
B 2 3
A 0 0
i want to make result if match with A then sum from column 2 and 3
so the results:
A 2 5 (5 Replies)
Discussion started by: justbow
5 Replies
8. Shell Programming and Scripting
this is part of a KT i am going thru.
i am writing a script in bash shell, linux where i have 2 columns where 1st signifies the nth hour like 00, 01, 02...23 and 2nd the file size.
sample data attached.
Desired output is 3 columns which will give the nth hour, number of entries in nth hour and... (3 Replies)
Discussion started by: alpha_1
3 Replies
9. Shell Programming and Scripting
Input file:
101M
10M10D20M1I70M
10M10D39M4I48M
10M10D91M
10M10I13M2I7M1I58M
10M10I15M1D66M
Output file:
101M 101 0 0
10M10D20M1I70M 100 1 10
10M10D39M4I48M 97 4 10
10M10D91M 101 0 10
10M10I13M2I7M1I58M 88 13 0
10M10I15M1D66M 91 10 1
I'm interested to count how many total of... (6 Replies)
Discussion started by: perl_beginner
6 Replies
10. UNIX for Beginners Questions & Answers
I have a file which need to be summed up using date column.
I/P:
2017/01/01 a 10
2017/01/01 b 20
2017/01/01 c 40
2017/01/01 a 60
2017/01/01 b 50
2017/01/01 c 40
2017/01/01 a 20
2017/01/01 b 30
2017/01/01 c 40
2017/02/01 a 10
2017/02/01 b 20
2017/02/01 c 30
2017/02/01 a 10... (6 Replies)
Discussion started by: Booo
6 Replies