[vox-tech] which tool is right for the job... (scripting
languages)
Rod Roark
rod at sunsetsystems.com
Fri Oct 1 11:40:59 PDT 2004
You can do this with any general-purpose programming
language, probably even awk (though my memory of it is a bit
rusty). I would use Perl, just because I know it better
than the others you mention.
General approach: create a hash of hashes, where the main
hash is keyed on "key", and has values that are hashes keyed
on "class" with corresponding values that are accumulated
percentages.
You didn't say what specific output is required, but you
should be able to generate it easily from the above.
-- Rod
On Friday 01 October 2004 11:01 am, Dylan Beaudette wrote:
> Greetings,
>
> I have a flat text file with records with the following properties:
> key, percent, class
>
> For any given key, there may be more than one record - with any 1 of 12
> possible classifications. The records occur in 2 types of patterns:
>
> 1) For a given key, it is clear which class is 'dominant' , as its
> percentage is the highest:
> ------------------------
> 458986,60,Inceptisols
> 458986,25,Mollisols
> ------------------------
>
> 2) For a given key, it is not alway clear which class is dominant, as
> some simple addition needs to be done in order to calculate the dominant
> class
> ------------------------
> 458987,30,Inceptisols
> 458987,30,Inceptisols
> 458987,20,Mollisols
> ------------------------
>
> For the first instance the dominant class could easily be extracted by
> sorting the records, but the second instance requires some addition and
> comparison... As the data is often more like the second instance, a
> generalized addition and comparison of classes for each unique key would
> be ideal.
>
> I am wondering what the best tool for doing this would be... I would
> like to keep the operation done with a minimal set of tools (i.e. bash
> and awk, python, perl) ... but unfortunatley I have not been able to get
> the program logic with bash quite right (i am more used to C style
> languages...)
>
> I know this is a littlew vague but any ideas on how to aggregate the
> various classes, and then compare them would be greatly appreciated!
>
> Thanks in advance!
>
> Dylan
More information about the vox-tech
mailing list