Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time


LibreCat-MARC2RDF - Catmandu examples for processing MARC data into RDF triples


  • Requires Perl 5.14 or better. Hit use plenv to install a recent perl
  $ plenv local 5.14

  $ git clone
  $ cd MARC2RDF
  $ cpanm


Display the contents of the MARC file:

  $ catmandu convert MARC to MARCMaker < data/camel.mrc

Convert the data/camel.mrc file to NTriples:

  $ catmandu convert MARC --fix fix/camel.fix --fix fix/marc_rdf_dct.fix to RDF --type NTriples < data/camel.mrc

Alternative, display not RDF but a YAML output

  $ catmandu convert MARC --fix fix/camel.fix --fix fix/marc_rdf_dct.fix to YAML < data/camel.mrc

Alternative, create a JSON-LD output (notice we use specialized marc_rdf_jsonld fix file for that and request catmandu to serialize in JSON)

  $ catmandu convert MARC --fix fix/camel.fix --fix fix/marc_rdf_jsonld.fix to JSON --pretty 1 < data/camel.mrc

The file fix/camel.fix contains specific fixes to create a subject for the RDF records. In the Fix file, the MARC 001 field is mapped to the _id field, which will be the subject for all triples.

The file fix/marc_rdf_dct.fix is a generic conversion script to map MARC to Dublin Core.

Optionally the file fix/viaf_lookup.fix can be added to attempt to lookup author names against the VIAF database using Linked Data Fragments:

  $ catmandu convert ALEPHSEQ --fix fix/rug01.fix --fix fix/marc_rdf_dct.fix --fix fix/viaf_lookup.fix to NTriples < data/rug01.aleph

In the example above we used the fact that the 'data/rug01.aleph' file has the Ex Libris Aleph sequential format instead of the ISO2709 MARC format.

Use Catmandu for more elaborate fixes and transformations

Big open catalog data sets are available at the Library of Congress.

  $ wget
  $ catmandu convert MARC --fix/loc.fix --fix fix/marc_rdf_dct.fix < BooksAll.2014.part01.utf8 > part01.nt


To convert MARC into RDF triples, the MARC field needs to be converted by Catmandu in a special format: aREF

To see how MARC looks like without any special conversions execute the command below:

  $ catmandu convert MARC to YAML < data/camel.mrc

The output will produce for every record in the MARC input a YAML document containing the _id of the MARC record and in record the MARC data. This record is an array of arrays. Mapping are needed to transform this array of arrays into the aREF format which is a hash. The Catmandu Fix language can be used to transform data in the MARC record to aREF fields. E.g.

   $ catmandu convert MARC --fix 'marc_map(245,dct_title); remove_field(record)' to YAML <   data/camel.mrc
 _id: 'fol05731351 '
 dct_title: ActivePerl with ASP and ADO /Tobias Martinsson.
 _id: 'fol05754809 '
 dct_title: Programming the Perl DBI /Alligator Descartes and Tim Bunce.

Maps the MARC 245 field to a Dublin Core title. Many mappings will be used to create RDF, this can all be done with Catmandu Fixes. To group all these fixes, they are written in a Fix script. When providing a Fix script on the command line all Fix commands in it will be executed.

   $ catmandu convert MARC --fix fix/camel.fix --fix fix/marc_rdf_dct.fix to YAML < data/camel.mrc

The command above will execute all the fixes in fix/camel.fix and fix/marc_rdf_dct.fix on each MARC record in the data/camel.mrc file.

The output of this command is the aREF format we are searching for:

- 2000@
- foaf_name: Martinsson, Tobias,@
  schema_birthDate: 1976@
- 2000@
- 2000@
- xxi, 289 p. :@
- 0471383147@
- 2000@
- eng@
- 'New York : John Wiley & Sons,@'
- QA76.73.P22 M33 2000@
- 005.13/3 21@
- Active server pages.@
- ActiveX.@
- Perl (Computer program language)@
- ActivePerl with ASP and ADO / Tobias Martinsson.@
- text@

When you delete the to YAML arguments from the command line then the default Catmandu Exporter defined in catmandu.yml RDF/NTriples will be executed which can understand aREF and transforms it into triples.

   $ catmandu convert  MARC --fix fix/camel.fix --fix fix/marc_rdf_dct.fix to NTriples < data/camel.mrc
 <> <> "eng" .
 <> <> "2000" .
 <> <> "2000" .
 <> <> "2000" .
 <> <> "2000" .
 <> <> "2000" .
 <> <> _:b1 .
 _:b1 <> "Martinsson, Tobias," .
 _:b1 <> "1976" .
 _:b1 <> "1976" .
 <> <> "2000" .
 <> <> "QA76.73.P22 M33 2000" .


  • I'm not an RDF/MARC expert, the example mappings provided don't use any of the recent work Bibo and other vocabularies
  • This project was created as part of the Catmandu project as an example how to create RDF triples from open data
  • I invite other developers to contribute to this code and provide better mappings


Patrick Hochstenbach, <patrick.hochstenbach at>


This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See for more information.


Example Fix scripts for transforming MARC to RDF triples







No releases published


No packages published