projects
/
virtual-ldap
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
ef97426
)
if field have # subfield delimiter, save splitted field into yaml
author
Dobrica Pavlinusic
<dpavlin@rot13.org>
Mon, 16 Mar 2009 10:02:46 +0000
(10:02 +0000)
committer
Dobrica Pavlinusic
<dpavlin@rot13.org>
Mon, 16 Mar 2009 10:02:46 +0000
(10:02 +0000)
bin/csv2yaml.pl
patch
|
blob
|
history
diff --git
a/bin/csv2yaml.pl
b/bin/csv2yaml.pl
index
bfe5702
..
5193e1e
100755
(executable)
--- a/
bin/csv2yaml.pl
+++ b/
bin/csv2yaml.pl
@@
-49,7
+49,7
@@
foreach my $line ( split(/\r?\n/, $csv) ) {
$v =~ s{\s+}{#}g if $n =~ m{tel};
$v =~ s[\x{17d}][F] if $n =~ m{spol};
- if ( $v =~ m{#} ) {
+ if ( $v =~ m{#} ) {
# subfields delimiter in CSV data
my @v = split(/\s*#+\s*/, $v);
foreach my $pos ( 0 .. $#v ) {
if ( $n =~ m{tel} ) {
@@
-61,8
+61,11
@@
foreach my $line ( split(/\r?\n/, $csv) ) {
}
$hash->{ $n . '_' . $pos } = $v[$pos];
}
+
+ $hash->{ $n } = [ @v ];
+ } else {
+ $hash->{ $n } = $v;
}
- $hash->{ $n } = $v;
}
warn dump( $hash ) if $debug;