Sorting exponential notation


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Sorting exponential notation
# 8  
Old 09-13-2010
Strange, I get:
Code:
$ sort -t\; -k2,2g infile
300890;4.27691979504843e-05;4;144469220
300890;4.27691979504843e-03;4;144469220
300890;4.27691979504843e-01;4;144469220

Which looks alright to me. Did you use: -t\; ?
# 9  
Old 09-13-2010
sorry I edit the text ..i think the reason is that i some columns are numbers and in others there are strings:

Code:
nils$ sort -t\; -k2,2g test.txt
 
XX10914755;0.0879836449881873-e10;1;33854866;CSMD2;T;C;I_2321282;POEA;8;43212072;43212115
XX12745618;0.00069063786440612;1;4019438;hCG_2036596;T;C;I_2321282;POEA;8;43212072;43212115
XX1547793;0.0000076396450281944;1;57739400;DAB1;T;C;I_2321282;POEA;8;43212072;43212115
XX3762296;0.00334938423169702;1;31003973;LAPTM5;A;G;I_2321282;POEA;8;43212072;43212115

# 10  
Old 09-13-2010
Hi, I think there is an error in your input file, no? If I use:
Code:
XX10914755;0.0879836449881873e-10;1;33854866;CSMD2;T;C;I_2321282;POEA;8;43212072;43212115
XX12745618;0.00069063786440612;1;4019438;hCG_2036596;T;C;I_2321282;POEA;8;43212072;43212115
XX1547793;0.0000076396450281944;1;57739400;DAB1;T;C;I_2321282;POEA;8;43212072;43212115
XX3762296;0.00334938423169702;1;31003973;LAPTM5;A;G;I_2321282;POEA;8;43212072;43212115

I get:
Code:
$ sort -t\; -k2,2g infile346c
XX10914755;0.0879836449881873e-10;1;33854866;CSMD2;T;C;I_2321282;POEA;8;43212072;43212115
XX1547793;0.0000076396450281944;1;57739400;DAB1;T;C;I_2321282;POEA;8;43212072;43212115
XX12745618;0.00069063786440612;1;4019438;hCG_2036596;T;C;I_2321282;POEA;8;43212072;43212115
XX3762296;0.00334938423169702;1;31003973;LAPTM5;A;G;I_2321282;POEA;8;43212072;43212115

# 11  
Old 09-13-2010
No there is no error .. I copied also yours ..i do not know whats wrong .. is there any other function, which I can use for sorting ..I am so confused know ;(
# 12  
Old 09-13-2010
I meant the - and the e were switched around in your example number: 0.0879836449881873-e10 should be 0.0879836449881873e-10 . What result did you get?

---------- Post updated at 00:52 ---------- Previous update was at 00:47 ----------

Is there a difference when you convert everything to scientific first? e.g.:
Code:
awk 'BEGIN{FS=OFS=";"}{$2=sprintf("%e",$2)}1' infile | sort -t\; -k2.2g

# 13  
Old 09-13-2010
yes..I have seen it ..but the problem still remains,


Code:
nils$ sort -t\; -k2,2g sort.txt 
XX10914755;0.0879836449881873e-10;1;33854866;CSMD2;T;C;I_2321282;POEA;8;43212072;43212115
XX12745618;0.00069063786440612;1;4019438;hCG_2036596;T;C;I_2321282;POEA;8;43212072;43212115
XX1547793;0.0000076396450281944;1;57739400;DAB1;T;C;I_2321282;POEA;8;43212072;43212115
XX3762296;0.00334938423169702;1;31003973;LAPTM5;A;G;I_2321282;POEA;8;43212072;43212115

I it sorts only for the first number before ".",e.g.
Code:
nils$ sort -t\; -k2,2g sort.txt 
XX1547793;1.0000076396450281944;1;57739400;DAB1;T;C;I_2321282;POEA;8;43212072;43212115
XX10914755;2.0879836449881873e-10;1;33854866;CSMD2;T;C;I_2321282;POEA;8;43212072;43212115
XX3762296;3.00334938423169702;1;31003973;LAPTM5;A;G;I_2321282;POEA;8;43212072;43212115
XX12745618;5.00069063786440612;1;4019438;hCG_2036596;T;C;I_2321282;POEA;8;43212072;43212115


I do not know ..whats wrong
# 14  
Old 09-13-2010
FWIW, I am getting:
Code:
XX10914755;2.0879836449881873e-10;1;33854866;CSMD2;T;C;I_2321282;POEA;8;43212072;43212115
XX1547793;1.0000076396450281944;1;57739400;DAB1;T;C;I_2321282;POEA;8;43212072;43212115
XX3762296;3.00334938423169702;1;31003973;LAPTM5;A;G;I_2321282;POEA;8;43212072;43212115
XX12745618;5.00069063786440612;1;4019438;hCG_2036596;T;C;I_2321282;POEA;8;43212072;43212115

using sort (GNU coreutils) 7.4
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Issue in round of and exponential value

we are facing an issue where the sum of column value is getting rounded of before and after decimal. $ awk -F "|" '{{sum = sum + $11}} END{print sum}' ARINSO_GLD001.txt 6.07398e+07 -- initial value $ awk -F "|" '{{sum = sum + $11}} END{print sum}' ARINSO_GLD001.txt | awk '{ print... (2 Replies)
Discussion started by: nadeemrafikhan
2 Replies

2. Shell Programming and Scripting

Perl: scientific notation to decimal notation

hello folks, I have few values in a log which are in scientific notation. I am trying to convert into actual decimal format or integer but couldn't able to convert. Values in scientific notation: 1.1662986666666665E-4 2.0946799999999998E-4 3.0741333333333333E-6 5.599999999999999E-7... (2 Replies)
Discussion started by: scriptscript
2 Replies

3. Shell Programming and Scripting

AWK - Avoid exponential value

I'm using the following command, but how can I avoid printing exponential value (highlighted):- awk ' BEGIN { OFS=FS="|" } { if(NF>4) $10=int(((3.77*$11)/100 + $11)); } { print } ' infile CR|20121022|105|GSM|N|SAN|00122|SAN|75082|6.03929e+06|5819880|5794769|25111... (7 Replies)
Discussion started by: Yoda
7 Replies

4. Shell Programming and Scripting

sum in exponential form

Hello guys, i have got a flat file and it has got balance amount value as one of its fields. my mission is to add the total of those balance values. i am getting that but the result is coming up in exponential form, which is not the right way. i want to see the sum as a normal decimal number but... (7 Replies)
Discussion started by: jdsony
7 Replies

5. Shell Programming and Scripting

Convertion from Exponential to Decimal

I am trying to read values from excel and perform some calculations but I am getting below error: expr 2.326227180240883E7 / 8.509366417956961E8 expr: non-numeric argument Can anyone let me know how do i convert thse exponential numbers to decimal. (2 Replies)
Discussion started by: sachinnayyar
2 Replies

6. Shell Programming and Scripting

Convert decimal notation to ANSI point code notation

wondering if anyone has any thoughts to convert the below thru a shell script Convert decimal signalling point notation to ANSI point code notation There is a site that does that conversion but i need to implement the solution in a shell script.....Thoughts.... OS: Solaris 9 ... (4 Replies)
Discussion started by: aavam
4 Replies

7. Shell Programming and Scripting

Exponential issues

I have the below awk command to search a row and find the line number. It returns the value in exponential. I understand we can use the print "%.0f\n" to convert the exponential. I wanted to have this in my awk command. Can anyone advise bnd=`awk '/^GS/{p=NR}$0~"^ABC.*\\*"k{f=1}/^GE/&&f{print... (3 Replies)
Discussion started by: Muthuraj K
3 Replies

8. Shell Programming and Scripting

exponential format

awk -F"\t" -vv1=$name 'BEGIN{OFS="\t"} {gsub ("http://www."v1".com","",$6);print $1"\t-\t-","",$6,$7,$9,$2,$14,$15"\t""Apache=-\t-",$8*1000000"\t-\t-\t-\tdeflate=-\trmt=-"}' file.txt > a.txt file.txt 144.130.7.153 www.chi.com - 18/Jul/2010:00:00:00 +0000 GET... (3 Replies)
Discussion started by: sandy1028
3 Replies

9. Shell Programming and Scripting

Turning off exponential notation in awk

I have various numbers that I'm printing out from a statistical summary script. I'd like it to stop using exponential format. Of course, I can use printf with 'd' and 'f' and various parameters to specify a format, but then it has other undesirable effects, like tacking on extra 0's or truncating... (0 Replies)
Discussion started by: treesloth
0 Replies

10. Shell Programming and Scripting

Convert exponential value to decimal

Hi, Here is my script to read a file into array: awk -F '+' ' # load first file into array indexed by fields 1 and 2 NR == FNR { file1nr = FNR for (i=3; i<NF; i++) { file1 = $i } I have this... (5 Replies)
Discussion started by: Sangtha
5 Replies
Login or Register to Ask a Question