projects
/
MojoFacets.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
2c54dc7
)
chomp whitespaces before and after value
author
Dobrica Pavlinusic
<dpavlin@rot13.org>
Sat, 16 Oct 2010 12:58:32 +0000
(14:58 +0200)
committer
Dobrica Pavlinusic
<dpavlin@rot13.org>
Sat, 16 Oct 2010 12:58:32 +0000
(14:58 +0200)
lib/MojoFacets/Import/CSV.pm
patch
|
blob
|
history
diff --git
a/lib/MojoFacets/Import/CSV.pm
b/lib/MojoFacets/Import/CSV.pm
index
de661c5
..
fc9b1eb
100644
(file)
--- a/
lib/MojoFacets/Import/CSV.pm
+++ b/
lib/MojoFacets/Import/CSV.pm
@@
-39,7
+39,7
@@
sub data {
my $header_line = shift @lines;
- my @header = map { s/^"(.+)"$/$1/; $_ } split( $delimiter, $header_line );
+ my @header = map { s/^"(.+)"$/$1/;
s/^\s*(.+?)\s*$/$1/;
$_ } split( $delimiter, $header_line );
warn "# header ",dump( @header );
while ( my $line = shift @lines ) {
@@
-49,6
+49,7
@@
sub data {
foreach my $i ( 0 .. $#v ) {
my $v = $v[$i];
$v =~ s/^"(.+)"$/$1/;
+ $v =~ s/^\s*(.+?)\s*$/$1/;
$item->{ $header[$i] || "f_$i" } = [ $v ];
}
push @{ $data->{items} }, $item;