Re: sorting file content by third numbered column
Le mercredi 14 mars 2018 09:31:24 UTC+1, Ni Va a écrit : > I have done this explained before. Dict that have total time in key and csv > line in value. > > > Then I can do a reverse(sort( numerical order but I would like to retrieve > values and the code above retrieve keys sorted. > so I need the last step. > > > . > . > > let line = funclass.s:sep.string(nOccur).s:sep.sumstr.s:sep.indicateur > call extend(s:sorted_by_total_time, {sumstr : line}) > > endfor > > let s:results_by_total_time = reverse(sort(keys(s:sorted_by_total_time),'N')) > > > > > > > > > > 2018-03-14 8:53 GMT+01:00 Christian Brabandt: > > > On Di, 13 Mär 2018, Ni Va wrote: > > > > > > Oh and BTW: please trim your quotes and write your statement below to > > > > what you are referring to. > > > > Please trim your quotes. > > > > Have you tried using a custom compare function similar to what is > > written to the help at :h sort()? > > > > BTW: please provide a minimal working example of what problem you are > > trying to solve. I am not trying to debug your complex script. Sorry. > > > > > > Best, > > Christian > > -- > > Es ist nicht genug, der Natur die Daumenschrauben anzulegen. > > Man muß auch hinhören, wenn sie aussagt. > > -- Arthur Schopenhauer > > > > > > -- > > -- > > You received this message from the "vim_use" maillist. > > Do not top-post! Type your reply below the text you are replying to. > > For more information, visit http://www.vim.org/maillist.php > > > > --- > > You received this message because you are subscribed to a topic in the Google > Groups "vim_use" group. > > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/vim_use/rjR-W-7MQNc/unsubscribe. > > To unsubscribe from this group and all its topics, send an email to > vim_use+unsubscr...@googlegroups.com. > > For more options, visit https://groups.google.com/d/optout. Would like to use map( but this seems to do the job. let s:results_by_total_time = [] for key in reverse(sort(keys(copy(s:sorted_by_total_time )),'N')) call add(s:results_by_total_time, s:sorted_by_total_time[key]) endfor Thank you. -- -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_use" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: sorting file content by third numbered column
I have done this explained before. Dict that have total time in key and csv line in value. Then I can do a reverse(sort( numerical order but I would like to retrieve values and the code above retrieve keys sorted. so I need the last step. . . let line = funclass.s:sep.string(nOccur).s:sep.sumstr.s:sep.indicateur call extend(s:sorted_by_total_time, {sumstr : line}) endfor let s:results_by_total_time = reverse(sort(keys(s:sorted_by_total_time),'N')) 2018-03-14 8:53 GMT+01:00 Christian Brabandt: > > On Di, 13 Mär 2018, Ni Va wrote: > > > > Oh and BTW: please trim your quotes and write your statement below to > > > what you are referring to. > > Please trim your quotes. > > Have you tried using a custom compare function similar to what is > written to the help at :h sort()? > > BTW: please provide a minimal working example of what problem you are > trying to solve. I am not trying to debug your complex script. Sorry. > > > Best, > Christian > -- > Es ist nicht genug, der Natur die Daumenschrauben anzulegen. > Man muß auch hinhören, wenn sie aussagt. > -- Arthur Schopenhauer > > -- > -- > You received this message from the "vim_use" maillist. > Do not top-post! Type your reply below the text you are replying to. > For more information, visit http://www.vim.org/maillist.php > > --- > You received this message because you are subscribed to a topic in the > Google Groups "vim_use" group. > To unsubscribe from this topic, visit https://groups.google.com/d/ > topic/vim_use/rjR-W-7MQNc/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > vim_use+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_use" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: sorting file content by third numbered column
On Di, 13 Mär 2018, Ni Va wrote: > > Oh and BTW: please trim your quotes and write your statement below to > > what you are referring to. Please trim your quotes. Have you tried using a custom compare function similar to what is written to the help at :h sort()? BTW: please provide a minimal working example of what problem you are trying to solve. I am not trying to debug your complex script. Sorry. Best, Christian -- Es ist nicht genug, der Natur die Daumenschrauben anzulegen. Man muß auch hinhören, wenn sie aussagt. -- Arthur Schopenhauer -- -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_use" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: sorting file content by third numbered column
On 13.03.18 07:41, Ni Va wrote: > The csv file attached below it produced from this code particularly by from > s:results list of strings. > > I import it into excel and then do a sort from max to min spent time by third > column. > > I would do the same from this vimscript below on in order to sort by numeric > float Total time column [Miles long inscrutably complex vimscript elided.] Vim is not emacs, so it does not burden itself with diverse functionality in the same way - and yet it has an inbuilt sort. OK, that apparently does not suffice for your requirements. Then the task is much more efficiently executed by existing tools designed for it. Have a look at "man sort". In a single short command line, you can replace all the wasteful complexity of a miles long inscrutable vimscript, instead handling which field to sort on, field separator, forward/reverse sort, numeric or alpha, etc. I repeat, one short line. A hammer can be used as a screwdriver, but only if you treat the screw as a nail. Results are likely to be disappointing. Erik -- I have yet to see any problem, however complicated, which, when you looked at it in the right way, did not become still more complicated. - Poul Anderson -- -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_use" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: sorting file content by third numbered column
Le mardi 13 mars 2018 14:34:20 UTC+1, Christian Brabandt a écrit : > On Di, 13 Mär 2018, Ni Va wrote: > > > By Total time column for example. > > Sorry, I find your answers in general too terse to try to figure out > what exactly you are trying to do now and I do not feel like guessing. > > It looks as you'd like to sort buffer content, while you were saying > before you want to sort lists. > > Oh and BTW: please trim your quotes and write your statement below to > what you are referring to. > > Thanks, > Christian > -- > Der gesunde Menschenverstand ist blind sowohl für das äußerst Böse > wie für das höchst Gute. > -- Karl Jaspers The csv file attached below it produced from this code particularly by from s:results list of strings. I import it into excel and then do a sort from max to min spent time by third column. I would do the same from this vimscript below on in order to sort by numeric float Total time column fun! helper#ybereportstats_timebyfunc(list) "{{{ "2. Total time by function " let totaltimelist = filter(copy(a:list), 'v:val =~ "TOTAL"') let pattime = '\(\d\+\:\d\+:\d\+\.\d\+\)' let patfunc = '\(\S\+()\)' let pattotaltime = '\(\d\+\(,\d\+\)\{0,1}\)' let linepat = '^.\{-}'.pattime.'.\{-}'.patfunc.'.\{-}'.pattotaltime.'.\{-}$' let listtotaltimespent = map(copy(totaltimelist)[0:s:nEch], 'substitute(v:val, linepat, "\\2@\\3@\\1", "")') " echomsg string(listtotaltimespent) " return for value in listtotaltimespent " k : class/func name " v : total time for the call.. " t : ..at time " try let [k,v,t] = split(value,'@') " catch /.*/ " echomsg 'error ' . string(value) " endtry if !has_key(s:dict,k) let s:dict[k] = { 'values' : [{'totaltime':v, 'time':t}] } else call extend(s:dict[k].values, [{'totaltime':v, 'time':t}]) endif endfor " echo s:dict " " 2. build results " let s:results = [join(["Func","Nb Occs", "Total time (ms)","Indicateur (ms/ech)"],s:sep)] for funclass in keys(s:dict) " Sum up total time for N occurs let nOccur = len(s:dict[funclass].values) " Sum up total time for N occurs let sum=0.0 for time in s:dict[funclass].values " echomsg time.totaltime let sum+=str2float(substitute(time.totaltime, ',', '.', 'g')) endfor " let sumstr = tr(printf("%s",sum),'.',',') let sumstr = printf("%s",sum) let indicateur=printf("%s",sum/nOccur) call extend(s:results, [funclass.s:sep.string(nOccur).s:sep.sumstr.s:sep.indicateur]) endfor " echomsg string(s:results) endfunction "}}} -- -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_use" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: sorting file content by third numbered column
On Di, 13 Mär 2018, Ni Va wrote: > By Total time column for example. Sorry, I find your answers in general too terse to try to figure out what exactly you are trying to do now and I do not feel like guessing. It looks as you'd like to sort buffer content, while you were saying before you want to sort lists. Oh and BTW: please trim your quotes and write your statement below to what you are referring to. Thanks, Christian -- Der gesunde Menschenverstand ist blind sowohl für das äußerst Böse wie für das höchst Gute. -- Karl Jaspers -- -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_use" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: sorting file content by third numbered column
Le mardi 13 mars 2018 12:18:31 UTC+1, Christian Brabandt a écrit : > On Mo, 12 Mär 2018, Ni Va wrote: > > > Thanks but it's a list content not a buffer content in my case. > > Write a custom Sort Function, that splits() your content and sorts on > the third field? > > BTW: Please provide complete exact examples. Makes it easier to > understand you and test. > > Best, > Christian > -- > Fast alles, was Menschen erfinden, wird früher oder später zur Waffe. > Ist das wirklich nicht zu verhindern? > -- Linus Pauling By Total time column for example. -- -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_use" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. Func;Nb Occs;Total time (ms);Indicateur (ms/ech) BarreOnglet_V2..ctor();1;10.4901;10.4901 ClassBoiteCde.DisposeDialogCde();2;0.132;0.066 EuriBoiteCde.set_CmdeEnCours();124;70.9966;0.572553 ClassPaveTexte.set_CouleurFondDesignation();173;6.6418;0.038392 ClassBoiteCde.CalcTailleIcone();146;8.9005;0.060962 BarreOnglet_V2.tabControl_SelectedIndexChanged();2;0.2234;0.1117 ClassPaveTexte.Calc();358;1164.8912;3.253886 ClassBoiteCde.FermeCmdeOnChgVue();158;7.5894;0.048034 EuriBoiteCde.set_CouleurSuspendu();146;30.149;0.2065 EuriIconeMemoNav.OnChgVueCourante();8;22.85;2.85625 EuriBoiteCde.set_CmdeEnDefaut();124;37.8138;0.30495 EuriLienZoneNavigation.set_Running();6;18.539;3.089833 BarreOnglet_V2.InitialiseOnglet();2;51.4192;25.7096 EuriIconeNav.set_NomIcone();60;20.9901;0.349835 ClassPaveTexte.CalcCouleurTexte();4682;1212.1025;0.258886 ClassPaveTexteListeNum.set_ListeCouleurFondTexte();108;9.6193;0.089068 ClassListeLienZoneNavigation.LoadAllZone();1;0.0581;0.0581 ClassPaveTexte.set_TaillePolice();20;0.9387;0.046935 BoutonClign.timer1_Tick();2015;81.6368;0.040515 ClassPaveTexte.GetCouleurTexte();3966;507.9232;0.128069 ClassPaveTexteListeNum.InitTableauEntier();196;16.7741;0.085582 ClassPaveTexteListeNum.set_ListeValeur();108;23.1277;0.214145 DonneeXML.TraiteXmlCoord();1;11.6919;11.6919 EuriPaveTexteListeNumQualite.Calc();130;629.2697;4.840536 EuriBoiteCde.set_CouleurFondTitre();146;31.7202;0.217262 EuriIconeMemoNav.AjouteNavigation2();2;10.0391;5.01955 ClassPaveTexte.SetCouleurTexte();358;347.7294;0.971311 ClassPaveTexte.set_Designation();173;6.4431;0.037243 EuriIconeNav..ctor();60;10.3819;0.173032 EuriBoiteCde.SetCoulFondBouton();372;108.9984;0.293006 ClassPaveTexte.set_AlignementTexte();173;15.792;0.091283 EuriIconeNav.set_Clic();60;2.1074;0.035123 ClassPaveTexte.set_PresenceCadre();41;1.6134;0.039351 EuriFondNavigation.set_CouleurFond();1;0.041;0.041 ClassPaveTexte.Dispose();6;0.3265;0.054417 EuriBoiteCde.Dispose();2;0.4785;0.23925 EuriBoiteCde.set_CouleurFondBouton();146;47.5052;0.325378 ClassPaveTexteListeNum.set_ListeTexte();108;7.9757;0.073849 ClassPaveTexte.set_CouleurFondTexte();303;14.0422;0.046344 BoutonClign..ctor();146;72.0876;0.493751 ClassBoiteCde.InitialiseListeIcone();146;475.0029;3.253445 ClassPaveTexte.GetCouleurFondTexte();3967;184.8867;0.046606 EuriFondNavigation.set_CheminImage();1;0.5861;0.5861 EuriIconeMemoNav.AnimeBouton();22;23.7136;1.077891 ClassListeMemoNavigation.MajNavigationBarreOnglet();2;20.2723;10.13615 ClassPaveTexteListeNum.Calc();130;614.7842;4.729109 ClassPaveTexte.set_EpaisseurCadre();173;15.9569;0.092236 EuriBarreOnglet_V2.InitialiseBarreOnglet();2;54.5657;27.28285 EuriFondNavigation..ctor();1;10.1322;10.1322 EuriBoiteCde.set_CouleurValide();146;41.6317;0.285149 ClassPaveTexteListeNum.set_Separateur();88;57.951;0.658534 EuriBoiteCde.InitialiseBoiteCmde();146;59.3302;0.406371 EuriBoiteCde.set_CmdeSuspendue();124;40.0737;0.323175 FondNavigation.InitialiseFond();1;14.9253;14.9253 BoutonClign.Dispose();2;0.3144;0.1572 DonneeXMLPano.TraiteXmlCouleur();2;6.7966;3.3983 EuriBoiteCde.set_CouleurSelect();146;83.7053;0.573324 ConvertCouleur2.GetRvb();1922;88.0787;0.045827 FondNavigation..ctor();1;4.541;4.541 ClassPaveTexte..ctor();173;139.7611;0.807868 EuriBarreOnglet_V2.Initialise();2;55.3131;27.65655 PaletteDiversCLS..ctor();1;9.6456;9.6456 EuriBarreOnglet_V2..ctor();1;14.3174;14.3174 EuriBoiteCde.set_CouleurSynoptique();146;34.4122;0.2357 EuriFondNavigation.set_Running();1;16.1461;16.1461 ClassPaveTexte.set_Texte();218;731.6541;3.356211 EuriIconeMemoNav.set_Designation();2;0.096;0.048 ClassLienZoneNavigation.set_PositionX();6;0.2254;0.037567 BarreOnglet_V2.BarreOngletsConforme();2;0.5106;0.2553 EuriBoiteCde.set_InstanceBoiteCde();146;14.5632;0.099748 ClassPaveTexte.set_Running();179;576.9326;3.223087 EuriBoiteCde..ctor();146;798.8035;5.471257 ClassListeMemoNavigation.AjouteNavigation2();2;8.2649;4.13245
Re: sorting file content by third numbered column
On Mo, 12 Mär 2018, Ni Va wrote: > Thanks but it's a list content not a buffer content in my case. Write a custom Sort Function, that splits() your content and sorts on the third field? BTW: Please provide complete exact examples. Makes it easier to understand you and test. Best, Christian -- Fast alles, was Menschen erfinden, wird früher oder später zur Waffe. Ist das wirklich nicht zu verhindern? -- Linus Pauling -- -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_use" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: sorting file content by third numbered column
Le lundi 12 mars 2018 22:19:41 UTC+1, Tim Rice a écrit : > Personally, I would pipe it through an external command, eg: > > :%! sort -n -k3 > > Within Vim on a Linux box that command results in text roughly like so for > me: > > Bar() 2 0.1320.066 > Foo.set_bar() 2 0.2234 0.1117 > FooBar.set_foo() 173 6.6418 0.038392 > Foo..ctor() 1 10.4901 10.4901 > FooBar.Calc() 358 1164.8912 3.253886 > > (I've manually inserted some space for readability reasons.) > > ~ Tim > > > On Mon, Mar 12, 2018 at 01:50:41PM -0700, Ni Va wrote: > > Hi, > > > > I don't happen to sort this kind of list by the third float numbered column. > > > > > > > > Foo..ctor()110.490110.4901 > > Bar()20.1320.066 > > FooBar.set_foo()1736.64180.038392 > > Foo.set_bar()20.22340.1117 > > FooBar.Calc()3581164.89123.253886 > > > > > > -- > > -- > > You received this message from the "vim_use" maillist. > > Do not top-post! Type your reply below the text you are replying to. > > For more information, visit http://www.vim.org/maillist.php > > > > --- > > You received this message because you are subscribed to the Google Groups > > "vim_use" group. > > To unsubscribe from this group and stop receiving emails from it, send an > > email to vim_use+unsubscr...@googlegroups.com. > > For more options, visit https://groups.google.com/d/optout. Thanks but it's a list content not a buffer content in my case. -- -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_use" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: sorting file content by third numbered column
Personally, I would pipe it through an external command, eg: :%! sort -n -k3 Within Vim on a Linux box that command results in text roughly like so for me: Bar() 2 0.1320.066 Foo.set_bar() 2 0.2234 0.1117 FooBar.set_foo() 173 6.6418 0.038392 Foo..ctor() 1 10.4901 10.4901 FooBar.Calc() 358 1164.8912 3.253886 (I've manually inserted some space for readability reasons.) ~ Tim On Mon, Mar 12, 2018 at 01:50:41PM -0700, Ni Va wrote: > Hi, > > I don't happen to sort this kind of list by the third float numbered column. > > > > Foo..ctor()110.490110.4901 > Bar()20.1320.066 > FooBar.set_foo()1736.64180.038392 > Foo.set_bar()20.22340.1117 > FooBar.Calc()3581164.89123.253886 > > > -- > -- > You received this message from the "vim_use" maillist. > Do not top-post! Type your reply below the text you are replying to. > For more information, visit http://www.vim.org/maillist.php > > --- > You received this message because you are subscribed to the Google Groups > "vim_use" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to vim_use+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. -- -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_use" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
sorting file content by third numbered column
Hi, I don't happen to sort this kind of list by the third float numbered column. Foo..ctor() 1 10.4901 10.4901 Bar() 2 0.132 0.066 FooBar.set_foo()173 6.6418 0.038392 Foo.set_bar() 2 0.2234 0.1117 FooBar.Calc() 358 1164.8912 3.253886 -- -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_use" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.