Finance-QuoteHist
view release on metacpan or search on metacpan
lib/Finance/QuoteHist/Generic.pm view on Meta::CPAN
}
sub csv_parser {
# Text::CSV_XS doesn't column slice or re-order, so we do.
my $self = shift;
my @patterns = $self->patterns(@_);
sub {
my $data = shift;
return [] unless defined $data;
my @csv_lines = ref $data ? <$data> : split("\n", $data);
# BOM squad (byte order mark, as csv from google tends to be)
if ($csv_lines[0] =~ s/^\xEF\xBB\xBF//) {
for my $i (0 .. $#csv_lines) {
utf8::decode($csv_lines[$i]);
}
}
# might be unix, windows, or mac style newlines
s/\s+$// foreach @csv_lines;
return [] if !@csv_lines || $csv_lines[0] =~ /(no data)|error/i;
# attempt to get rid of comments at front of csv data
while (@csv_lines) {
( run in 0.438 second using v1.01-cache-2.11-cpan-e9daa2b36ef )