Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
440Z0220-932§other information 623Z5400-1§other information 623Z5400-1§other information 623Z5400-18other information 623Z5400-18§other information 623Z5400-3§other information 623Z5420-1301§other information 623Z5420-1307§other information 7010902H01§other information 7010900H01§other information 623Z5466-1013§other information 623Z5466-1015§other information 623Z5465-1039§other information 623Z5465-1041§other information 623Z5465-1001§other information 623Z5420-3301§other information 623Z5465-41§other information 623Z5462-1001§other information 623Z5462-1003§other information 7010902H01§other information 623Z5420-3307§other information B3-15838§other information 623Z5422-3307§other information
623Z5462-1003§Other information 623Z5468-1§Other information 623Z5468-9§Other information 623Z5468-7§Other information 623Z5468-5§Other information CA623Z5462-1003§Other information BACD40AC36B30§Other information 623Z5469-7§Other information 623Z5462-3§Other information
623Z5465-1001§other information 623Z5465-1§other information 623Z5465-11§other information CA623Z5465-1001§other information
0 440Z0220-932§other information 1 440Z0220-932§other information 1 623Z5400-1§other information 1 623Z5400-1§other information 1 623Z5400-18other information 1 623Z5400-18§other information 1 623Z5400-3§other information 1 623Z5420-1301§other information 1 623Z5420-1307§other information 1 7010902H01§other information 1 7010900H01other information 1 623Z5466-1013§other information 1 623Z5466-1015§other information 1 623Z5465-1039§other information 1 623Z5465-1041§other information 1 623Z5465-1001§other information 1 623Z5420-3301§other information 1 623Z5465-41§other information 1 623Z5462-1001§other information 2 623Z5465-1§other information 2 623Z5465-11§other information 2 CA623Z5465-1001§other information 1 623Z5462-1003§other information 2 623Z5462-1003§Other information 2 623Z5468-1§Other information 2 623Z5468-9§Other information 2 623Z5468-7§Other information 2 623Z5468-5§Other information 2 CA623Z5462-1003§Other information 2 BACD40AC36B30§Other information 2 623Z5469-7§Other information 2 623Z5462-3§Other information 1 7010902H01§other information 1 623Z5420-3307§other information 1 B3-15838§other information 1 623Z5422-3307§other information
#!/usr/bin/perl $folder_IN=$ARGV[0]; $level=0; $finaltreefile="./final.CSV"; $rootfile=`ls $folder_IN/$level*.CSV`; print "rootfile: $rootfile\n"; &treebuilder($rootfile); sub treebuilder{ $PRESENTLEVELFILE=shift; print "File level $level : $PRESENTLEVELFILE\n"; $level++; open(PRESENTLEVELFILE); while ($leafline=<PRESENTLEVELFILE>){ print "Leggo $leafline\n"; chomp($leafline); if ($. == 1){ if($PRESENTLEVELFILE =~ /^0*/i){ open(FINAL,">$finaltreefile"); print FINAL "0 $leafline\n"; close(FINAL); } next; }else{ print "next level=$level\n"; @element=split('§',$leafline); chomp($element[0]); print "Find $element[0]\n"; $NEXTLEVELFILE=$folder_IN."/".$level."_".$element[0].".CSV"; chomp($NEXTLEVELFILE); print "Check if file exists: $NEXTLEVELFILE\n"; if (-e $NEXTLEVELFILE){ print "$NEXTLEVELFILE !esiste!\n"; &treebuilder($NEXTLEVELFILE); open(FINAL,">>$finaltreefile"); $level++; print FINAL "$level $leafline\n"; close FINAL; } print "$NEXTLEVELFILE ?not exists?\n"; open(FINAL,">>$finaltreefile"); print FINAL "$level $leafline\n"; close FINAL; } } }
0 440Z0220-932§other information 1 440Z0220-932§other information 1 623Z5400-1§other information 1 623Z5400-1§other information 1 623Z5400-18other information 1 623Z5400-18§other information 1 623Z5400-3§other information 1 623Z5420-1301§other information 1 623Z5420-1307§other information 1 7010902H01§other information 1 7010900H01§other information 1 623Z5466-1013§other information 1 623Z5466-1015§other information 1 623Z5465-1039§other information 1 623Z5465-1041§other information 1 623Z5465-1001§other information 1 623Z5420-3301§other information 1 623Z5465-41§other information 1 623Z5462-1001§other information 2 623Z5465-1§other information 2 623Z5465-11§other information 2 CA623Z5465-1001§other information
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: create a level csv
by ELISHEVA (Prior) on Apr 16, 2009 at 08:49 UTC | |
by Paulux (Acolyte) on Apr 16, 2009 at 09:30 UTC | |
by ELISHEVA (Prior) on Apr 16, 2009 at 13:05 UTC | |
|
Re: create a level csv
by Utilitarian (Vicar) on Apr 16, 2009 at 08:44 UTC | |
|
Re: create a level csv
by ig (Vicar) on Apr 16, 2009 at 11:10 UTC | |
by Paulux (Acolyte) on Apr 16, 2009 at 15:01 UTC | |
by ig (Vicar) on Apr 16, 2009 at 18:51 UTC | |
by Paulux (Acolyte) on Apr 17, 2009 at 07:18 UTC |