unixbreak Posted March 13, 2014 Report Posted March 13, 2014 Salut,am niste fisiere csv pe care vreau sa le concatenez intr-unu singur fisier si sa le ordonez numeric. Problema e ca idul dupa care ordonez nu respecta o notatie standard. de ex . sort -f *.csv > output.csv merge daca idul respecta forma id001 id002 id010 id100. Idurile pt fisierele mele sunt id1 id2 id10 id100 si asta imi strica sortarea.sort -t, -V *.csv > output.csv merge perfect face exact ce imi trebuie pe masina de test care are sort --version gnu coreutils 8.5.0 nu 5.3.0 versiunea de la munca. Si bineinteles nu era implementata -V in 5.3.0ma simt noob ... dar si ghinionist. Daca va plictisiti si aveti o idee mai buna, bring it on !Multumesc Quote
Elohim Posted March 13, 2014 Report Posted March 13, 2014 Mai esti online? Da-mi aici paste repede la cum arata id-urile si prin ce sunt delimitate campurile, sa vad ce pot sa ii fac. Quote
unixbreak Posted March 13, 2014 Author Report Posted March 13, 2014 (edited) cn41 XXXXXXXX XXXXXXXX 9C:B6:54:08:A3:C6 9C:B6:54:08:A3:C4 9C:B6:54:08:A3:C5 dar ordonez dupa id > cn41si idiurile sunt de forma cn1 cn2 cn10 cn100 si campurile sunt delimitate prin virgula ... e csv Edited March 13, 2014 by unixbreak Quote
unixbreak Posted March 27, 2014 Author Report Posted March 27, 2014 am facut un script perl pt asta ... in caz ca cineva are nevoie pe viitor ... #!/usr/bin/perl$infile = $ARGV[0];if (!-e $infile){$infile = "unsorted.csv";};open (IN, "<$infile"); @RAW){$curline =~ s/\n//g;@pieces = split(",", $curline);$id = substr($pieces[1], 2);$tmphash{$id} = $curline;};foreach $key (sort {$a <=> $b} keys %tmphash){print $tmphash{$key} . "\n";};executati perl script.pl unsorted.csv > sorted.csv Quote