How to calculate avg values of csv file using shell scripting .?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to calculate avg values of csv file using shell scripting .?
# 1  
Old 01-13-2016
RedHat How to calculate avg values of csv file using shell scripting .?

hi all i have a reporting work and i want it to be automated using shell scripting kindly let me know how can i make that possibe .

eg data are :
Code:
Date,Time,nl45.1,nl45.2,nl45.3,nl45.4,nl46.1,nl46.2,nl46.3,nl46.4,nl46.5,nl47.1,nl47.2,nl47.3,nl47.4,nl47.5,nl48.1,nl48.2,nl48.3,nl48.4,nl49.1,nl49.2,nl49.3,nl50.1,nl50.2,nl50.3,nl50.4,nl50.5*
12-01-2016,00:00,1,1,1,0,,0,1,1,0,0,0,0,1,3,1,1,0,0,0,,0,0,0,,,1,1,0,6,0,*
12-01-2016,00:10,1,0,0,0,,2,1,1,1,0,0,0,0,1,1,1,0,0,0,,0,0,1,,,0,0,0,1,0,*
12-01-2016,00:20,0,0,1,0,,0,0,0,0,0,0,0,1,0,0,1,0,0,0,,0,0,0,,,2,0,0,0,0,*
12-01-2016,00:30,0,0,0,0,,1,0,0,1,0,0,2,2,0,0,0,0,0,0,,0,1,1,,,0,0,0,0,0,*
12-01-2016,00:40,0,0,1,0,,1,0,1,0,0,0,0,0,1,1,0,0,0,0,,0,2,0,,,0,0,0,0,1,*
12-01-2016,00:50,0,0,0,0,,0,0,1,0,0,0,0,0,0,0,0,0,0,0,,0,0,0,,,1,0,0,1,1,*


Last edited by Don Cragun; 01-13-2016 at 05:35 AM.. Reason: Add CODE tags.
# 2  
Old 01-13-2016
Hello and welcome to the forum.
Please use code tags for code blocks, as you have accepted by the forum rules.

Since this post is similar (if not identical) to
If this is a homework, please refer to the homework section of the forum and follow the guidelines that apply there.

Either way, any attempts from your side yet?
# 3  
Old 01-13-2016
In addition to what sea has already said, you need to provide a much clearer description of what you are trying to do. Are you looking for a single number that is the average value of the values all non-time, non-asterisk, non-empty, non-header fields? Are you looking for the average of values in each line? Are you looking for the average of values in each column? Are empty fields to be treated as zero and included in the average(s) or skipped?

At the very least, show us the output you hope to produce (in CODE tags) from the sample input you provided.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Read csv file, convert the data and make one text file in UNIX shell scripting

I have input data looks like this which is a part of a csv file 7,1265,76548,"0102:04" 8,1266,76545,"0112:04" I need to make the output data should look like this and the output data will be part of text file: 7|1265000 |7654899 |A| 8|12660000 |76545999 |B| The logic behind the... (6 Replies)
Discussion started by: RJG
6 Replies

2. Shell Programming and Scripting

Need a piece of shell scripting to remove column from a csv file

Hi, I need to remove first column from a csv file and i can do this by using below command. cut -f1 -d, --complement Mytest.csv I need to implement this in shell scripting, Whenever i am using the above command alone in command line it is working fine. I have 5 files in my directory and... (3 Replies)
Discussion started by: Samah
3 Replies

3. Shell Programming and Scripting

How to calculate average of csv using shell scripting?

Hi, I need to calculate the average of the following values using shell scripitng. Can anyone please suggest a solution? ... (10 Replies)
Discussion started by: karan pratap si
10 Replies

4. Shell Programming and Scripting

Shell scripting:from text file to CSV

Hello friends, I have a file as follows: "empty line" content1 content2 content3 content1 content2 content3 content1 content2 content3 It starts with an empty line, how can i get a csv like this: (12 Replies)
Discussion started by: kraterions
12 Replies

5. Shell Programming and Scripting

Calculate avg response time on hourly basis

Hi, I am trying to calculate avg response time on hourly basis from the log file which has millions of records. As of now I am trying with creating temp file which will have lines with unique id and start time and end time and after that another script will run on this temp file to... (7 Replies)
Discussion started by: random_thoughts
7 Replies

6. Shell Programming and Scripting

How to insert a sequence number column inside a pipe delimited csv file using shell scripting?

Hi All, I need a shell script which could insert a sequence number column inside a dat file(pipe delimited). I have the dat file similar to the one as shown below.. |A|B|C||D|E |F|G|H||I|J |K|L|M||N|O |P|Q|R||S|T As shown above, the column 4 is currently blank and i need to insert sequence... (5 Replies)
Discussion started by: nithins007
5 Replies

7. Shell Programming and Scripting

Korn shell program to parse CSV text file and insert values into Oracle database

Enclosed is comma separated text file. I need to write a korn shell program that will parse the text file and insert the values into Oracle database. I need to write the korn shell program on Red Hat Enterprise Linux server. Oracle database is 10g. (15 Replies)
Discussion started by: shellguy
15 Replies

8. Shell Programming and Scripting

How to calculate months and display in shell scripting

I just want to know, how do we calculate the months in shell scripting. If i give the input as 20-01-2011, the output should be 20-02-2011, 20-03-2011 or 20-04-2011........ How do i get this ? Cheers. (6 Replies)
Discussion started by: sachin24
6 Replies

9. Shell Programming and Scripting

How can I read values from a CSV file using Shell?

SHELL SCRIPT Hi, I have a file in which contents are as follows: 9999,abdc,123 9988,aba_12,2323 and so on I want to read the contents of this file such that i can do echo "This is $a followed by $b an then $c" I tried the following but id did not work cat test | cut -d ',' -f1|... (7 Replies)
Discussion started by: mayanksargoch
7 Replies

10. Shell Programming and Scripting

Need to compare two csv files values and write into another csv file

Hi all, Am new to scripting. So i just need your ideas to help me out. Here goes my requirement. I have two csv files 1.csv 2.csv abc,1.24 abc,1 def,2.13 def,1 I need to compare the first column of 1.csv with 2.csv and if matches then need to compare... (2 Replies)
Discussion started by: chinnahyd
2 Replies
Login or Register to Ask a Question