Revision bfb0d001
Von Sven Schöling vor mehr als 13 Jahren hinzugefügt
SL/Helper/Csv.pm | ||
---|---|---|
212 | 212 |
|
213 | 213 |
my $status = $csv->parse; |
214 | 214 |
my $hrefs = $csv->get_data; |
215 |
my @objects = $scv->get_objects; |
|
215 |
my @objects = $csv->get_objects; |
|
216 |
|
|
217 |
my @errors = $csv->errors; |
|
216 | 218 |
|
217 | 219 |
=head1 DESCRIPTION |
218 | 220 |
|
... | ... | |
222 | 224 |
most cases you will want those line to be parsed into hashes or even objects, |
223 | 225 |
so this model just skips ahead and gives you objects. |
224 | 226 |
|
225 |
Encoding autodetection is not easy, and should not be trusted. Try to avoid it |
|
226 |
if possible. |
|
227 |
Its basic assumptions are: |
|
228 |
|
|
229 |
=over 4 |
|
230 |
|
|
231 |
=item You do know what you expect to be in that csv file. |
|
232 |
|
|
233 |
This means first and foremost you have knowledge about encoding, number and |
|
234 |
date format, csv parameters such as quoting and separation characters. You also |
|
235 |
know what content will be in that csv and what L<Rose::DB> is responsible for |
|
236 |
it. You provide valid header columns and their mapping to the objects. |
|
237 |
|
|
238 |
=item You do NOT know if the csv provider yields to your expectations. |
|
239 |
|
|
240 |
Stuff that does not work with what you expect should not crash anything, but |
|
241 |
give you a hint what went wrong. As a result, if you remeber to check for |
|
242 |
errors after each step, you should be fine. |
|
243 |
|
|
244 |
=item Data does not make sense. It's just data. |
|
245 |
|
|
246 |
Almost all data imports have some type of constraints. Some data needs to be |
|
247 |
unique, other data needs to be connected to existing data sets. This will not |
|
248 |
happen here. You will receive a plain mapping of the data into the class tree, |
|
249 |
nothing more. |
|
250 |
|
|
251 |
=back |
|
227 | 252 |
|
228 | 253 |
=head1 METHODS |
229 | 254 |
|
... | ... | |
249 | 274 |
|
250 | 275 |
=item C<errors> |
251 | 276 |
|
252 |
Return all errors that came up druing parsing. See error handling for detailed
|
|
277 |
Return all errors that came up during parsing. See error handling for detailed
|
|
253 | 278 |
information. |
254 | 279 |
|
255 | 280 |
=back |
Auch abrufbar als: Unified diff
Mehr Dokumentation