calculation of average from a csv file using shell script
I have a csv file having values of four different parameters . The values of the parameters for a single day are many and I want to find the average of the values using a shell script.
My csv file looks like this year month date time rainfall(cm) 2012 12 5 10.00 12 2012 12 5 12.00 14 2013 04 3 10.00 16 2013 04 3 12.00 17 I want to calculate the average of rainfall for a single day.How to write a shell script for this? |
Welcome to LQ :)
Please show what you have attempted so far? |
Agreed it would be nice to show your efforts to this point.
I think a simple awk script would be an easy solution which would also provide decimal average values which a shell script will not do. By way of encouragement I wrote a quick and dirty awk which does the following pseudo-code (assumes dates are not interleaved, prints average for each date): Code:
BEGIN { Code:
awk -f rain.awk rain_data |
If interested in interpreting large amounts of data, you can try using pandas with python
https://pandas.pydata.org/ Code:
import pandas as pd |
That's pretty impressive ... ;)
ISTR Sefyir pushing this barrow before. I keep trying to convince myself there must be a reason to learn python ... maybe there is. |
All times are GMT -5. The time now is 04:49 AM. |