l i n u x - u s e r s - g r o u p - o f - d a v i s
L U G O D
 
Next Meeting:
September 2: Social gathering
Next Installfest:
TBD
Latest News:
Aug. 18: Discounts to "Velocity" in NY; come to tonight's "Photography" talk
Page last updated:
2004 Oct 02 09:08

The following is an archive of a post made to our 'vox-tech mailing list' by one of its subscribers.

Report this post as spam:

(Enter your email address)
Re: [vox-tech] which tool is right for the job... (scriptinglanguages)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [vox-tech] which tool is right for the job... (scriptinglanguages)




depending on how large your dataset is, you may be able to do it with perl hashes- something like this:

perl -e '

while ($line=<STDIN>){
chomp($line);($key,$percent,$value)=split(/,/,$line);
$hash{$key}->{value}+=$percent;
}
foreach $key (keys(%hash)){
foreach $value(keys(%$key)){
$max{$key}=$hash{$key}->{$value} if($hash{$key}->{$value} >$max{key});

}
foreach $key(keys(%hash)){ print "$key,$max{$key}\n"}
}


or something like that.

On Fri, 1 Oct 2004, 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
_______________________________________________
vox-tech mailing list
vox-tech@lists.lugod.org
http://lists.lugod.org/mailman/listinfo/vox-tech

_______________________________________________
vox-tech mailing list
vox-tech@lists.lugod.org
http://lists.lugod.org/mailman/listinfo/vox-tech



LinkedIn
LUGOD Group on LinkedIn
Sign up for LUGOD event announcements
Your email address:
facebook
LUGOD Group on Facebook
'Like' LUGOD on Facebook:

Hosting provided by:
Sunset Systems
Sunset Systems offers preconfigured Linux systems, remote system administration and custom software development.

LUGOD: Linux Users' Group of Davis
PO Box 2082, Davis, CA 95617
Contact Us

LUGOD is a 501(c)7 non-profit organization
based in Davis, California
and serving the Sacramento area.
"Linux" is a trademark of Linus Torvalds.

Sponsored in part by:
Sunset Systems
Who graciously hosts our website & mailing lists!