[librecat-dev] Sorting MARC records with Catmandu
Patrick.Hochstenbach at UGent.be
Thu Sep 14 08:58:58 CEST 2017
There are many ways to do this. Basically the algoritm is:
* Extract the field you want to sort from MARC using marc_map
* Store the data somewhere (in memory, in a Catmandu::Store, …)
* Sort and export back to MARC
You can do this on the command line also with the TSV exporter and to_json,from_json command to transform MARC into a line-by-record serialisation and sort this one using the UNIX ‘sort’ command. E.g.
catmandu convert MARC to TSV --header 0 --fix 'marc_map(245a,__sort); to_json(record)’ < camel.mrc \
| sort \
| catmandu convert TSV --fields '__sort,_id,record' to MARC --fix 'from_json(record)’
> On 13 Sep 2017, at 16:25, Uldis Bojars <captsolo at gmail.com> wrote:
> Can Catmandu help with sorting a set of MARC records (by certain MARC fields / subfields)?
> Since records are normally processed sequentially and separately, it does not seem like a good fit. But perhaps you have some advice on how to do it.
> A quick-and-dirty non-Catmandu solution 'd be a custom script to load records into memory, to index / sort them by the required fields and to output them in this order.
> 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/
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 455 bytes
Desc: Message signed with OpenPGP
More information about the librecat-dev