[librecat-dev] my.very.deep.path in Catmandu::Fix::marc_spec
Patrick Hochstenbach
Patrick.Hochstenbach at UGent.be
Mon Jun 13 15:34:59 CEST 2016
This works on my side:
catmandu -I lib convert MARC to YAML --fix 'marc_map(245b,my.title.medium); retain(my)' < t/camel.usmarc
I get the my.title.medium when there is a 245b field and no my.title.medium when not
Patrick
> On 13 Jun 2016, at 08:31, Klee, Carsten <Carsten.Klee at sbb.spk-berlin.de> wrote:
>
> Hi Nicolas!
>
> Great, that works!
>
> One question left:
>
> marc_spec("245", my.title.$append)
>
> makes 'my.title' an array. Now if I try something like
>
> marc_spec("245$h", my.title.medium)
>
> it will fail silently. I understand this. But shouldn't there be a warning or something? The user might think that there is no subfield 'h'.
>
> Cheers!
>
> Carsten
>
>
>
>> -----Ursprüngliche Nachricht-----
>> Von: Nicolas Steenlant [mailto:Nicolas.Steenlant at UGent.be]
>> Gesendet: Freitag, 10. Juni 2016 14:38
>> An: Klee, Carsten
>> Cc: librecat-dev at lists.uni-bielefeld.de
>> Betreff: Re: [librecat-dev] my.very.deep.path in Catmandu::Fix::marc_spec
>>
>> Hi Carsten,
>>
>> Catmandu::Util has some internal (and undocumented) functions that help
>> with this:
>>
>> use Catmandu::Util qw(:data);
>> use Data::Dumper;
>> my $data = {};
>> my $nested = data_at('my.very.deep', $data, create => 1, key => 'path');
>> set_data($nested, 'path', 'a value');
>> print Dumper($data);
>>
>> $VAR1 = {'my' => {'very' => {'deep' => {'path' => 'a value'}}}};
>>
>> Calling data_at without the create => 1 option will not make missing
>> intermediate structures
>> and return undef in this case.
>> The key => ‘path’ option gives a hint to data_at that you want ‘deep’ to be a
>> hash
>> and not an array,
>> since it can’t guess the type by looking at the next segment of the path.
>>
>> Regards,
>> Nicolas
>>
>> --
>> Nicolas Steenlant
>> Ghent University Library
>>
>> Sint-Hubertusstraat 8
>> 9000 Gent
>>
>> nicolas.steenlant at ugent.be
>> +32 486 62 62 27
>>
>>
>>> On 10 Jun 2016, at 14:05, Klee, Carsten <Carsten.Klee at sbb.spk-berlin.de>
>> wrote:
>>>
>>> Hi Catmandu monks!
>>>
>>> I’m currently working on the Catmandu::Fix::marc_spec [1]. I chose to stick
>> with a simple ‘fix’ method (emit is quite hairy and Perl is difficult enough to
>> learn).
>>>
>>> To make long things short: How do I get my referenced data into the
>> my.very.deep.path?
>>>
>>> I read https://librecatproject.wordpress.com/2014/03/26/create-a-fixer-
>> part-2/ . But is there an easy way to reuse the Catmandu::Fix methods in a
>> non emit method?
>>>
>>> Cheers!
>>>
>>> Carsten
>>>
>>>
>>> [1] <https://github.com/cKlee/Catmandu-Fix-marc_spec>
>>>
>>>
>>> _______________________________________________
>>> Carsten Klee
>>> Abt. Überregionale Bibliographische Dienste IIE
>>> Staatsbibliothek zu Berlin – Preußischer Kulturbesitz
>>> Potsdamer Straße 33
>>> 10785 Berlin
>>>
>>> Fon: +49 30 266-43 44 02
>>> Fax: +49 30 266-33 40 01
>>> carsten.klee at sbb.spk-berlin.de
>>> www.zeitschriftendatenbank.de
>>> _______________________________________________
>>> librecat-dev mailing list
>>> - send list mails to librecat-dev at lists.uni-bielefeld.de
>>> - to unsubscribe or change options, visit https://lists.uni-
>> bielefeld.de/mailman2/cgi/unibi/listinfo/librecat-dev
>>> - project website: http://librecat.org/
>
>
> _______________________________________________
> librecat-dev mailing list
> - send list mails to librecat-dev at lists.uni-bielefeld.de
> - to unsubscribe or change options, visit https://lists.uni-bielefeld.de/mailman2/cgi/unibi/listinfo/librecat-dev
> - project website: http://librecat.org/
Patrick Hochstenbach - digital architect
University Library Ghent
Sint-Hubertusstraat 8 - 9000 Ghent - Belgium
patrick.hochstenbach at ugent.be
+32 (0)9 264 7980
More information about the librecat-dev
mailing list