The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Parse::Stallion::CSVFH - Comma Separated Values from file handle

SYNOPSIS

  This is primarily for demonstrating Parse::Stallion.

  use Parse::Stallion::CSVFH;

  my $csv_stallion = new Parse::Stallion::CSVFH;

  my $file_handle;
  open $file_handle, "<", "csv_file";

  my $result = eval {$csv_stallion->
   parse_and_evaluate({string=>$file_handle})};

  if ($@) {
    if ($stallion->parse_failed) {#parse failed};
  }
  # else $result contains reference to array of arrays

If the file handle refers to a file containing:

 "abc sdf, sdf",add,eff
 jff,"slk,lwer,sd
 sdfkl,sdf,sdf,sdf",ke
 lkwer,fsjk,sdf

Then result will be:

 { 'header' => [ 'abc sdf, sdf', 'add', 'eff' ],
   'records' => [
     [ 'jff', "slk,lwer,sd\nsdfkl,sdf,sdf,sdf", 'ke' ],
     [ 'lkwer', 'fsjk', 'sdf' ]
    ]
 }

DESCRIPTION

Reads a comma separated value file via a given file handle, returning a reference to a hash containing the headers and the data.