http://qs321.pair.com?node_id=73161


in reply to Re: Text::xSV
in thread Text::xSV

The API for Text::CSV has you hand lines off to the module to parse. This is incompatible with having the module detect that a return is embedded in a field and so another line needs to be fetched to parse the row. I didn't see any easy way to provide anything like a compatible interface to the current one which handled embedded returns. Therefore I felt that it was best to provide the functionality in a new module with a new API.

Note that the API for Text::CSV_XS is able to handle embedded returns, and I should update this to mention that. However the API they chose seemed specific to their implementation, so I didn't try to tie out to it.

Replies are listed 'Best First'.
Re (tilly) 1: Text::xSV
by graff (Chancellor) on Apr 12, 2002 at 18:12 UTC
    Tilly, I'd like to suggest an addition to Text::xSV. It would be useful for the calling program to access the list of field header strings that are found in / bound from the first row of a CSV file; i.e. add a method like "get_header" as follows:
    sub bind_header { my $self = shift; $self->bind_fields($self->get_row()); $self->{field_name} = [ @{$self->{row}} ]; # this is new delete $self->{row}; } # the following method is new: sub get_header { my $self = shift; if ( exists( $self->{field_name} )) { return wantarray ? @{$self->{field_name}} : $self->{field_name +}; } }

    That works for me, but maybe you would want to do it a little differently. Thanks very much for this module, and for your discussions in various threads about CSV data -- you got my vote.

      I intend to retake maintainance of Text::xSV again. I had hoped to have time to make various improvements today, but that doesn't look viable at this point. :-(

      However within a month it should sprout some hopefully nice goodies. :-)