[librecat-dev] Sorting MARC records with Catmandu
captsolo at gmail.com
Tue Sep 26 15:22:33 CEST 2017
Note: the last command (conversion back to MARC) also has to have "--header
I also needed to sort by multiple keys. Ended up writing a simple Python
script for the sorting step.
On 14 September 2017 at 09:58, Patrick Hochstenbach <
Patrick.Hochstenbach at ugent.be> wrote:
> 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:
> > Hi,
> > 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.
> > Thanks,
> > Uldis
> > _______________________________________________
> > 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.
> > - project website: http://librecat.org/
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the librecat-dev