Changeset 32817 for main/trunk/model-sites-dev/heritage-nz/collect/reports-2019/perllib/plugins/CSVPlugin.pm
- Timestamp:
- 2019-02-25T22:21:24+13:00 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/model-sites-dev/heritage-nz/collect/reports-2019/perllib/plugins/CSVPlugin.pm
r32812 r32817 116 116 my $csv_file_field_line = $1; 117 117 118 my $separate_char = $self->{' separate_char'};118 my $separate_char = $self->{'csv_field_separator'}; 119 119 if ($separate_char =~ m/^auto$/i) { 120 120 $separate_char = $self->resolve_auto($csv_file_field_line,$self->{'plugin_type'},$self->{'outhandle'},$self->{'verbosity'}); … … 133 133 } 134 134 135 # $csv_file_field_line .= $separate_char; # To make the regular expressions simpler # ****136 137 # while ($csv_file_field_line ne "") {138 # # Handle quoted values139 # 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 names142 # push(@csv_file_fields, $csv_file_field);143 # }144 # # Normal comma-separated case145 # 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 names148 # push(@csv_file_fields, $csv_file_field);149 # }150 # # The line must be formatted incorrectly151 # else {152 # print STDERR "Error: Badly formatted CSV field line: $csv_file_field_line.\n";153 # last;154 # }155 # }156 157 135 $self->{'csv_file_fields'} = \@csv_file_fields; 158 136 159 print STDERR "****** csvfile fields joined = ", join(" ||| ", @{$self->{'csv_file_fields'}}), "\n";137 # print STDERR "**** CSV file fields joined = ", join(" ||| ", @{$self->{'csv_file_fields'}}), "\n"; 160 138 } 161 139 … … 196 174 } 197 175 198 199 200 # # Build a hash of metadata name to metadata value for this line201 # 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 quoted205 # if ($csv_line =~ s/^\"(.*?)\"${separate_char}//) { # ****206 # # Only bother with non-empty values207 # 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 case213 # elsif ($csv_line =~ s/^(.*?)${separate_char}//) { # ****214 # # Only bother with non-empty values215 # 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 incorrectly221 # else {222 # print STDERR "Error: Badly formatted CSV line: $csv_line.\n";223 # last;224 # }225 226 # $i++;227 # }228 229 176 # Record was processed successfully 230 177 return 1;
Note:
See TracChangeset
for help on using the changeset viewer.