Hello all,
@Pete
You got me thinking about some good additional functions, and before I knew it I was coding again...
I have added some new functionality to fields.awk.
Feel free to download and tinker with the upgraded version, fields_ext.awk.
This is a real zip archive (.bz2) so you have to unzip it.
The two main additions are:
1) a column-adding feature (function "addcol") added to the main menu (select T for tally/total)
2) a search output filtering option, offered whenever you save a read-search to file.
Also, though the default search-output file folder is still ~/Desktop, you can now easily change that
by editing the line (found at the script beginning just after the preamble):
SEARCH_DIR=~/Desktop
to reflect your desired location. Just make sure it actually exists
A handy short database file (weather_data.txt) for testing the "tally" function:
@@@DATE::mm_RAIN::uV_rads::lightning_strikes::
05-10-16::60::0.89::3::
05-15-16::12::0.54::1::
05-20-16::74::2.1::6::
05-25-16::98::0.34::3::
05-30-16::987::.87::7::
06-05-16::0::.23::0::
06-10-16::45::0::14::
06-15-16::10::.59::1::
06-20-16::10::1.0::2::
06-25-16::36::.10::15::
Select this file and choose "T" from main menu, then select field#2 for adding:
Note it offers an option to filter the tally, that is add the numbers in selected field only for records pertaining to a search string.
In this example I've selected for only the "June" entries by using the search string "06-"
DATE || mm_RAIN || uV_rads || lightning_strikes ||
Which field column would you like to total? (Enter an integer)
2
Total of column#2 = 1332.00
___________________________________________
Try a filtered tally?
y
Enter filter string:
(Default case-insensitive; only those records including the string will be tallied)
06-
The following is your _filtered_ tally result:
Total of column#2 = 101.00
___________________________________________
Hit ENTER to return to main menu ...
==============================================================
For the search output filter function using the same small database, if you save a search file including all the records, then select a filtered output including only DATE and mm_RAIN, the interface looks like this:
Your file was saved as weather.txt in /home/iforsyth/DB_FILES/SEARCHES.
Filter output?
y
DATE || mm_RAIN || uV_rads || lightning_strikes ||
Select # of fields to display (2-4)
2
Enter string for field selection#1:
DATE
Enter string for field selection#2:
mm_RAIN
Your filtered output was saved as weather_f2.txt in /home/iforsyth/DB_FILES/SEARCHES.
Hit ENTER to return to main menu ...
Note: the output filter can handle either 2, 3, or 4 field selections for filtering.
Hope you find these additions useful.
Cheers,
Ian