Thread 1 file in mehreren kleine file spliten
(4 answers)
Opened by Henri at 2015-07-11 20:37
Hallo Leute ich möchte die File result_3.csv in mehrere file.csv leider schafe ich es nicht, das ist was ich schon gemacht habe. Danke für ihre Hilfe.
Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 use strict; use warnings FATAL => 'all'; use autodie; open(INPUT, '<', 'result_3.csv'); my $nombre=0; my @fichiers; while((my $ligne=<INPUT> )) { next if($ligne=~/^\d+\s+\d{2}:\d{2}:\d{2}\s*$/); next if($ligne=~/^\s+$/); next if($ligne=~/^default/); if($ligne=~/,fault,/) { $nombre++; push @fichiers, (split(/,/, $ligne))[0]; } } close(INPUT); open(OUTPUT, '>', 'resultat.txt'); print OUTPUT join("\n", @fichiers); close(OUTPUT); _____________________DATA_________________________ 20150627 19:08:00 default, prim, second, copy_direct, forced_copy, always_allow, type_of_dump, full_memory, d100spupt, /dev/lg_du, /dev/sysdu, /var/adm, 1, 1, fault, disallow, doc10, 5, fault, 7, ad8, 9, wu, disallow, doc11, 5, fault, 5g7, 8, te, 10, disallow, doc12, 5, fault, 7, ca, 9hg, 10, disallow, doc13, 5, fault, 7, 8, 35hg, 10, disallow, ____________________OUTPUT______________________________ Output: file1 prim: d100spupt : /dev/lg_du doc10 : 5 doc11 : 5 doc12 : 5 doc 13 : 5 Output: file2 second: d100spupt : /dev/sysdu doc10 : fault doc11 : fault doc12 : fault doc 13 : fault Output: file3 copy_direct: d100spupt : /var/adm doc10 : 7 doc11 : 5g7 doc12 : 7 doc 13 :7 ... ... ... Output: file7 full_memory: d100spupt : disallow doc10 : disallow doc11 : disallow doc12 : disallow doc 13 :disallow Last edited: 2015-07-11 22:22:22 +0200 (CEST) |