Fixed: Thingy importing with newlines embedded in CSV fields
This commit is contained in:
parent
bba4753beb
commit
c80a966f91
3 changed files with 31 additions and 9 deletions
|
|
@ -22,12 +22,12 @@ use Text::CSV_XS;
|
|||
use base 'Exporter';
|
||||
|
||||
our @EXPORT_OK = qw(
|
||||
joinCSV splitCSV
|
||||
joinCSV readCSV splitCSV
|
||||
|
||||
);
|
||||
|
||||
our %EXPORT_TAGS = (
|
||||
"csv" => [qw( joinCSV splitCSV )],
|
||||
"csv" => [qw( joinCSV readCSV splitCSV )],
|
||||
|
||||
);
|
||||
|
||||
|
|
@ -45,6 +45,11 @@ WebGUI::Text - Routines for manipulating text.
|
|||
use WebGUI::Text qw(:csv);
|
||||
my $string = joinCSV(@array);
|
||||
my @array = splitCSV($string);
|
||||
|
||||
while(my $row = readCSV($fileHandle) {
|
||||
my @fields = @{ $row };
|
||||
doSomethingWith(@fields);
|
||||
}
|
||||
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
|
@ -79,6 +84,20 @@ sub joinCSV {
|
|||
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 readCSV ( $fileHandle )
|
||||
|
||||
Reads a record from the passed filehandle and returns an arrayref of the columns read.
|
||||
|
||||
=cut
|
||||
|
||||
sub readCSV {
|
||||
my $fileHandle = shift;
|
||||
my $row = $csv->getline($fileHandle);
|
||||
return $row;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 splitCSV ( $string )
|
||||
|
|
@ -105,12 +124,11 @@ sub splitCSV {
|
|||
|
||||
=item *
|
||||
|
||||
splitCSV doesn't properly handle quoted fields with no text inside (...,"",...)
|
||||
None known.
|
||||
|
||||
=back
|
||||
|
||||
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
=over 4
|
||||
|
|
@ -119,6 +137,10 @@ splitCSV doesn't properly handle quoted fields with no text inside (...,"",...)
|
|||
|
||||
RFC 4180 (http://tools.ietf.org/html/rfc4180)
|
||||
|
||||
=item *
|
||||
|
||||
L<Text::CSV_XS>
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue