--- trunk/all2xml.pl 2003/06/23 20:20:32 54 +++ trunk/all2xml.pl 2003/07/04 16:56:40 58 @@ -18,7 +18,8 @@ my $config; -use index_DBI; # there is no other, right now ;-) +#use index_DBI; # default DBI module for index +use index_DBI_cache; # faster DBI module using memory cache my $index; my %opts; @@ -33,7 +34,7 @@ my $path; # this is name of database -Text::Iconv->raise_error(1); # Conversion errors raise exceptions +Text::Iconv->raise_error(0); # Conversion errors don't raise exceptions # this is encoding of all files on disk, including import_xml/*.xml file and # filter/*.pm files! It will be used to store strings in perl internally! @@ -240,14 +241,18 @@ print STDERR "reading ./import_xml/$type.xml\n"; - $config=XMLin("./import_xml/$type.xml", forcearray => [ $type2tag{$type} ], forcecontent => 1); + # extract just type basic + my $type_base = $type; + $type_base =~ s/_.+$//g; + + $config=XMLin("./import_xml/$type.xml", forcearray => [ $type2tag{$type_base} ], forcecontent => 1); # output current progress indicator my $last_p = 0; sub progress { #return if (! $opts{q}); # FIXME my $current = shift; - my $total = shift; + my $total = shift || 1; my $p = int($current * 100 / $total); if ($p != $last_p) { printf STDERR ("%5d / %5d [%-51s] %-2d %% \r",$current,$total,"=" x ($p/2).">", $p ); @@ -258,7 +263,8 @@ # now read database print STDERR "using: $type...\n"; - if ($type eq "isis") { + if ($type_base eq "isis") { + my $isis_db = $cfg -> val($database, 'isis_db') || die "$database doesn't have 'isis_db' defined!"; $import2cp = Text::Iconv->new($config->{isis_codepage},$codepage); @@ -278,7 +284,7 @@ my $swishpath = $path."#".int($row->{mfn}); - if (my $xml = data2xml($type,$row,$add_xml)) { + if (my $xml = data2xml($type_base,$row,$add_xml)) { $xml = $cp2utf->convert($xml); use bytes; # as opposed to chars print "Path-Name: $swishpath\n"; @@ -289,7 +295,7 @@ } print STDERR "\n"; - } elsif ($type eq "excel") { + } elsif ($type_base eq "excel") { use Spreadsheet::ParseExcel; use Spreadsheet::ParseExcel::Utility qw(int2col); @@ -297,7 +303,7 @@ my $excel_file = $cfg -> val($database, 'excel_file') || die "$database doesn't have 'excel_file' defined!"; my $sheet = x($config->{sheet}) || die "no sheet in $type.xml"; - my $start_row = x($config->{start_row}) || die "no start_row in $type.xml"; + my $start_row = x($config->{start_row}) - 1 || die "no start_row in $type.xml"; my $oBook = Spreadsheet::ParseExcel::Workbook->Parse($excel_file) || die "can't open Excel file '$excel_file'"; @@ -314,7 +320,7 @@ defined ($oWorksheet) || die "can't find sheet '$sheet' in $excel_file"; my $end_row = x($config->{end_row}) || $oWorksheet->{MaxRow}; - for(my $iR = $oWorksheet->{MinRow} ; defined $end_row && $iR <= $end_row ; $iR++) { + for(my $iR = $start_row ; defined $end_row && $iR <= $end_row ; $iR++) { my $row; for(my $iC = $oWorksheet->{MinCol} ; defined $oWorksheet->{MaxCol} && $iC <= $oWorksheet->{MaxCol} ; $iC++) { my $cell = $oWorksheet->{Cells}[$iR][$iC];