Revision da364d0f
Von Kivitendo Admin vor fast 10 Jahren hinzugefügt
SL/Helper/Csv.pm | ||
---|---|---|
119 | 119 |
0, |
120 | 120 |
0]) unless $info_ok; |
121 | 121 |
|
122 |
# If header is given, there need to be a header for each profile |
|
122 |
# If header is given, there needs to be a header for each profile
|
|
123 | 123 |
# and no empty headers. |
124 | 124 |
if ($info_ok && $self->header) { |
125 | 125 |
my @header = @{ $self->header }; |
... | ... | |
195 | 195 |
# people insist that case sensitivity doesn't exist and try to enter all |
196 | 196 |
# sorts of stuff. at this point we've got a profile (with keys that represent |
197 | 197 |
# valid methods), and a header full of strings. if two of them match, the user |
198 |
# mopst likely meant that field, so rewrite the header
|
|
198 |
# most likely meant that field, so rewrite the header |
|
199 | 199 |
if ($self->case_insensitive_header) { |
200 | 200 |
die 'case_insensitive_header is only possible with profile' unless $self->profile; |
201 | 201 |
if ($header) { |
... | ... | |
221 | 221 |
sub _check_multiplex_datatype_position { |
222 | 222 |
my ($self) = @_; |
223 | 223 |
|
224 |
return 1 if !$self->is_multiplexed; # ok if if not multiplexed
|
|
224 |
return 1 if !$self->is_multiplexed; # ok if not multiplexed |
|
225 | 225 |
|
226 | 226 |
my @positions = map { firstidx { 'datatype' eq lc($_) } @{ $_ } } @{ $self->header }; |
227 | 227 |
my $first_pos = $positions[0]; |
... | ... | |
368 | 368 |
|
369 | 369 |
See Synopsis. |
370 | 370 |
|
371 |
Text::CSV offeres already good functions to get lines out of a csv file, but in
|
|
372 |
most cases you will want those line to be parsed into hashes or even objects, |
|
371 |
Text::CSV already offers good functions to get lines out of a csv file, but in
|
|
372 |
most cases you will want those lines to be parsed into hashes or even objects,
|
|
373 | 373 |
so this model just skips ahead and gives you objects. |
374 | 374 |
|
375 | 375 |
Its basic assumptions are: |
... | ... | |
378 | 378 |
|
379 | 379 |
=item You do know what you expect to be in that csv file. |
380 | 380 |
|
381 |
This means first and foremost you have knowledge about encoding, number and |
|
381 |
This means first and foremost that you have knowledge about encoding, number and
|
|
382 | 382 |
date format, csv parameters such as quoting and separation characters. You also |
383 | 383 |
know what content will be in that csv and what L<Rose::DB> is responsible for |
384 | 384 |
it. You provide valid header columns and their mapping to the objects. |
... | ... | |
493 | 493 |
In this case C<listprice_as_number> will be used to read in values from the |
494 | 494 |
C<listprice> column. |
495 | 495 |
|
496 |
In case of a One-To-One relationsship these can also be set over
|
|
497 |
relationsships by sparating the steps with a dot (C<.>). This will work:
|
|
496 |
In case of a One-To-One relationship these can also be set over |
|
497 |
relationships by separating the steps with a dot (C<.>). This will work:
|
|
498 | 498 |
|
499 | 499 |
[ {profile => { customer => 'customer.name' }} ] |
500 | 500 |
|
Auch abrufbar als: Unified diff
Typos in Doku