Changeset 32817

Show
Ignore:
Timestamp:
25.02.2019 22:21:24 (8 months ago)
Author:
davidb
Message:

Change of option name

Location:
main/trunk/model-sites-dev/heritage-nz/collect/reports-2019/perllib/plugins
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/model-sites-dev/heritage-nz/collect/reports-2019/perllib/plugins/CSVFieldSeparator.pm

    r32812 r32817  
    3939my $arguments =  
    4040    [  
    41       { 'name' => "separate_char", 
    42     'desc' => "{CSVFieldSeparator.separate_char}", 
     41      { 'name' => "csv_field_separator", 
     42    'desc' => "{CSVFieldSeparator.csv_field_separator}", 
    4343    'type' => "string", 
    4444    'deft' => "auto", 
  • main/trunk/model-sites-dev/heritage-nz/collect/reports-2019/perllib/plugins/CSVPlugin.pm

    r32812 r32817  
    116116    my $csv_file_field_line = $1; 
    117117 
    118     my $separate_char = $self->{'separate_char'}; 
     118    my $separate_char = $self->{'csv_field_separator'}; 
    119119    if ($separate_char =~ m/^auto$/i) { 
    120120    $separate_char = $self->resolve_auto($csv_file_field_line,$self->{'plugin_type'},$self->{'outhandle'},$self->{'verbosity'}); 
     
    133133    } 
    134134 
    135     # $csv_file_field_line .= $separate_char;  # To make the regular expressions simpler # **** 
    136  
    137     # while ($csv_file_field_line ne "") { 
    138     #   # Handle quoted values 
    139     #   if ($csv_file_field_line =~ s/^\"(.*?)\"${separate_char}//) { # **** 
    140     #       my $csv_file_field = $1; 
    141     #       $csv_file_field =~ s/ //g;  # Remove any spaces from the field names 
    142     #       push(@csv_file_fields, $csv_file_field); 
    143     #   } 
    144     #   # Normal comma-separated case 
    145     #   elsif ($csv_file_field_line =~ s/^(.*?)${separate_char}//) { # **** 
    146     #       my $csv_file_field = $1; 
    147     #       $csv_file_field =~ s/ //g;  # Remove any spaces from the field names 
    148     #       push(@csv_file_fields, $csv_file_field); 
    149     #   } 
    150     #   # The line must be formatted incorrectly 
    151     #   else { 
    152     #       print STDERR "Error: Badly formatted CSV field line: $csv_file_field_line.\n"; 
    153     #       last; 
    154     #   } 
    155     # } 
    156  
    157135    $self->{'csv_file_fields'} = \@csv_file_fields; 
    158136 
    159     print STDERR "****** csv file fields joined = ", join(" ||| ", @{$self->{'csv_file_fields'}}), "\n"; 
     137    # print STDERR "**** CSV file fields joined = ", join(" ||| ", @{$self->{'csv_file_fields'}}), "\n"; 
    160138} 
    161139 
     
    196174    } 
    197175 
    198  
    199  
    200     # # Build a hash of metadata name to metadata value for this line 
    201     # my $i = 0; 
    202     # $csv_line .= $separate_char;  # To make the regular expressions simpler # **** 
    203     # while ($csv_line ne "") { 
    204     #   # Metadata values containing commas are quoted 
    205     #   if ($csv_line =~ s/^\"(.*?)\"${separate_char}//) { # **** 
    206     #       # Only bother with non-empty values 
    207     #       my $match = $1; 
    208     #       if ($match ne "" && defined($csv_file_fields[$i])) { 
    209     #       $doc_obj->add_utf8_metadata($section, $csv_file_fields[$i], $match); 
    210     #       } 
    211     #   } 
    212     #   # Normal comma-separated case 
    213     #   elsif ($csv_line =~ s/^(.*?)${separate_char}//) { # **** 
    214     #       # Only bother with non-empty values 
    215     #       my $match = $1; 
    216     #       if ($match ne "" && defined($csv_file_fields[$i])) { 
    217     #       $doc_obj->add_utf8_metadata($section, $csv_file_fields[$i], $match); 
    218     #       } 
    219     #   } 
    220     #   # The line must be formatted incorrectly 
    221     #   else { 
    222     #       print STDERR "Error: Badly formatted CSV line: $csv_line.\n"; 
    223     #       last; 
    224     #   } 
    225  
    226     #   $i++; 
    227     # } 
    228  
    229176    # Record was processed successfully 
    230177    return 1; 
  • main/trunk/model-sites-dev/heritage-nz/collect/reports-2019/perllib/plugins/MetadataCSVPlugin.pm

    r32812 r32817  
    144144    $csv_file_content =~ s/\n+/\n/g; 
    145145 
    146     my $separate_char = $self->{'separate_char'}; 
     146    my $separate_char = $self->{'csv_field_separator'}; 
    147147 
    148148    my @csv_file_lines = split(/\n/, $csv_file_content); 
     
    165165    } 
    166166 
    167 ##    my @csv_file_fields = split(/${separate_char}/, $csv_file_field_line); # **** 
    168167    my $found_filename_field = 0; 
    169168    for (my $i = 0; $i < scalar(@csv_file_fields); $i++) { 
     
    210209        last; 
    211210    } 
    212  
    213     # my $i = 0; 
    214     # $csv_line .= "$separate_char";  # To make the regular expressions simpler 
    215     # while ($csv_line ne "") { 
    216     #     # Metadata values containing commas are quoted 
    217     #     if ($csv_line =~ s/^\"(.*?)\"${separate_char}//) { # **** 
    218     #   # Only bother with non-empty values 
    219     #   if ($1 ne "" && defined($csv_file_fields[$i])) { 
    220     #       if (!defined $csv_line_metadata{$csv_file_fields[$i]}) { 
    221     #       $csv_line_metadata{$csv_file_fields[$i]} = []; 
    222     #       } 
    223     #       push (@{$csv_line_metadata{$csv_file_fields[$i]}}, $1); 
    224     #   } 
    225     #     } 
    226     #     # Normal comma-separated case 
    227     #     elsif ($csv_line =~ s/^(.*?)${separate_char}//) { # **** 
    228     #   # Only bother with non-empty values 
    229     #   if ($1 ne "" && defined($csv_file_fields[$i])) { 
    230     #       if (!defined $csv_line_metadata{$csv_file_fields[$i]}) { 
    231     #       $csv_line_metadata{$csv_file_fields[$i]} = []; 
    232     #       } 
    233     #       # remove any surrounding quotes. (When exporting to CSV, some spreadsheet 
    234     #       # programs add quotes even around field values that don't contain commas.) 
    235     #       my $value = $1; 
    236     #       $value =~ s/^"//; 
    237     #       $value =~ s/"$//; 
    238     #       push (@{$csv_line_metadata{$csv_file_fields[$i]}}, $value); 
    239     #   } 
    240     #     } 
    241     #     # The line must be formatted incorrectly 
    242     #     else { 
    243     #   $self->print_error($outhandle, $failhandle, $gli, $filename_full_path, "Badly formatted CSV line: $csv_line"); 
    244     #   last; 
    245     #     } 
    246  
    247     #     $i++; 
    248     # } 
    249211 
    250212    # We can't associate any metadata without knowing the file to associate it with