Closed schwabmi closed 3 years ago
Hi,
pica_map
can just be used with PICA data formats (see https://pro4bib.github.io/pica/#/formate), not arbitrary JSON data structures.
Examples:
# fetch some PICA data via SRU & map title
$ catmandu convert -v SRU --base http://sru.k10plus.de/gvk \
--recordSchema picaxml --parser picaxml --query 'code4lib' \
--fix 'pica_map(021Aa,dc_title);remove_field(record)' \
to JSON --pretty 1
# or with file input
$ catmandu convert PICA to JSON --pretty 1 \
--fix 'pica_map(021Aa,dc_title);remove_field(record)' \
< pica.dat
Best
Johann
Hi, thanks for the answer. Unfortunately, the example:
$ catmandu convert -v SRU --base http://sru.k10plus.de/gvk \
--recordSchema picaxml --parser picaxml --query 'code4lib' \
--fix 'pica_map(021Aa,dc_title);remove_field(record)' \
to JSON --pretty 1
results in the same error as before:
Oops! Tried to execute the fix 'pica_map' but can't find Catmandu::Fix::pica_map on your system.
Error: No such fix package: pica_map
Package name: Catmandu::Fix::pica_map
Fix name: pica_map
Source:
pica_map(021Aa,dc_title);remove_field(record)
Cheers Michel
Ah, sorry. You have to add the modules to your Perl installation:
$ cpanm Catmandu::PICA Catmandu::SRU
I already got them installed:
Catmandu::PICA is up to date. (1.03)
Catmandu::SRU is up to date. (0.429)
Please check the output of
$ catmandu info
and check for the modules.
Catmandu::PICA | 1.03 | Catmandu modules for working with PICA+ data
Catmandu::Fix::pica_map | 1.03 | copy pica values of one field to a new field
Catmandu::SRU | 0.429 | Catmandu module for working with SRU data
They all appear in the list.
Windows or Unix?
Unix (Ubuntu 18.04.5 LTS)
Weird. Can you convert PICA data without a fix?
$ wget https://raw.githubusercontent.com/gbv/Catmandu-PICA/master/t/files/picaplus.dat
$ catmandu convert PICA --type plus to JSON < picaplus.dat
Yes that works!
Ok, but I still have no idea why the fixes don't work...
Could you please try to run catmandu
with a local lib:
$ git clone https://github.com/gbv/Catmandu-PICA.git
$ cd Catmandu-PICA
$ catmandu -I lib/ convert PICA --type plus to JSON \
--fix 'pica_map(021Aa,title);remove_field(record);' < picaplus.dat
... or you can try to install a local perl
version with perlbrew
:
# install perlbrew
$ \curl -L https://install.perlbrew.pl | bash
# edit .bashrc
$ echo -e '\nsource ~/perl5/perlbrew/etc/bashrc\n' >> ~/.bashrc
$ source ~/.bashrc
# initialize
$ perlbrew init
# see what versions are available
$ perlbrew available
# install a Perl version
$ perlbrew install -j 2 -n perl-5.28.2
# see installed versions
$ perlbrew list
# switch to an installation and set it as default
$ perlbrew switch perl-5.28.2
# install cpanm
$ perlbrew install-cpanm
# install some Catmandu modules
$ cpanm Catmandu Catmandu::Breaker Catmandu::Exporter::Table \
Catmandu::Identifier Catmandu::Importer::getJSON Catmandu::MARC Catmandu::OAI \
Catmandu::PICA Catmandu::PNX Catmandu::RDF Catmandu::SRU Catmandu::Stat \
Catmandu::Template Catmandu::VIAF Catmandu::Validator::JSONSchema \
Catmandu::Wikidata Catmandu::XLS Catmandu::XSD Catmandu::Z3950
Thanks a lot! It did not work with the local lib, but with perlbrew!
Hi
i try to use
pica_map
, but I get the following error when I execute the following command:catmandu convert JSON --fix 'pica_map(021A, dc_title)' < test.json
When I look into the install moduls via
catmandu info
, it says:Catmandu::Fix::pica_map | 1.03 | copy pica values of one field to a new field
Catmandu version:
catmandu (Catmandu::CLI) version 1.2015 (/usr/bin/catmandu)
I also use e.g.
pica_add()
which works.Cheers Michel