Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision f74b0dac

Von Sven Schöling vor mehr als 8 Jahren hinzugefügt

  • ID f74b0dac7a8e55cc7a67c4a03a3ee229415b3fbd
  • Vorgänger 621248de
  • Nachfolger a0d9f09a

Csv: mapping support

Unterschiede anzeigen:

SL/Helper/Csv/Dispatcher.pm
113 113
  my $i = 0;
114 114
  foreach my $header (@{ $h_aref }) {
115 115
    my $spec = $self->_parse_profile(profile => $csv_profile->[$i]->{profile},
116
                                     mapping => $csv_profile->[$i]->{mapping},
116 117
                                     class   => $csv_profile->[$i]->{class},
117 118
                                     header  => $header);
118 119
    push @specs, $spec;
......
132 133
  my $profile = $params{profile};
133 134
  my $class   = $params{class};
134 135
  my $header  = $params{header};
136
  my $mapping = $params{mapping};
135 137

  
136 138
  my @specs;
137 139

  
138 140
  for my $col (@$header) {
139 141
    next unless $col;
140
    if ($self->_csv->strict_profile) {
141
      if (exists $profile->{$col}) {
142
        push @specs, $self->make_spec($col, $profile->{$col}, $class);
143
      } else {
144
        $self->unknown_column($col, undef);
145
      }
142
    if (exists $mapping->{$col} && $profile->{$mapping->{$col}}) {
143
      push @specs, $self->make_spec($col, $profile->{$mapping->{$col}}, $class);
144
    } elsif (exists $mapping->{$col}) {
145
      push @specs, $self->make_spec($col, $mapping->{$col}, $class);
146
    } elsif (exists $profile->{$col}) {
147
      push @specs, $self->make_spec($col, $profile->{$col}, $class);
146 148
    } else {
147
      if (exists $profile->{$col}) {
148
        push @specs, $self->make_spec($col, $profile->{$col}, $class);
149
      if ($self->_csv->strict_profile) {
150
        $self->unknown_column($col, undef);
149 151
      } else {
150 152
        push @specs, $self->make_spec($col, $col, $class);
151 153
      }

Auch abrufbar als: Unified diff