[librecat-dev] marc_rename

Patrick Hochstenbach Patrick.Hochstenbach at UGent.be
Thu Jul 20 11:24:08 CEST 2017


You can do a cut and past on every field and do the renaming:


# For each marc field...

do marc_each()
   # Cut the field into tmp..
   marc_cut(***,tmp)

   # Rename every 1 subfield to 0
   rename(tmp.*.subfields.*,1,0)

   # And paste it back
   marc_paste(tmp)
end

The `rename` fix allows regexes so you can replace '1' with any regex you like.

Cheers
Patrick


________________________________
From: librecat-dev-bounces at lists.uni-bielefeld.de <librecat-dev-bounces at lists.uni-bielefeld.de> on behalf of Schihin Oliver <Oliver.Schihin at zhbluzern.ch>
Sent: Thursday, July 20, 2017 10:46 AM
To: librecat-dev at lists.uni-bielefeld.de
Subject: [librecat-dev] marc_rename

Hi

Is there an easy way to rename MARC subfield codes (not values) according to a regex condition? I am sure someone has an easy trick I just can't find.

Case: Due to ALEPH internals, subfields holding identifiers are $1, not $0 as in the standard. I should change these in a conversion (MARC to MARC).

Idea:
```
marc_cut(...1,tmp,equal:'regexthatmatchesidentifiers')
rename(tmp, '1', '0')
marc_paste(tmp)
```
Downside is the positioning of the pasting, even with the at: parameter.

Ideal would be a fix like 'marc_rename' that allows for a selection with a regex.

Thanks for hints
Oliver

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.uni-bielefeld.de/mailman2/unibi/public/librecat-dev/attachments/20170720/22636912/attachment.html>


More information about the librecat-dev mailing list