<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Hi,</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
I don't think al the fixes in your fix script I can recognise as intended usage of marc fixes. But, I understood hopefully the gist of what you are trying to achieve. Here is my take on a script that can do that for you</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<p class="elementToProof" style="margin-top: 0px; margin-bottom: 0px;"><span style="font-family: Menlo; font-size: 14px; color: rgb(0, 0, 0);">do marc_each()</span></p>
<p style="line-height: normal; margin: 0px;"><span style="font-family: Menlo; font-size: 14px; color: rgb(0, 0, 0);"> if marc_has('773w')</span></p>
<p style="line-height: normal; margin: 0px;"><span style="font-family: Menlo; font-size: 14px; color: rgb(0, 0, 0);"> marc_map('773w',tmp,split:1)</span></p>
<p style="line-height: normal; margin: 0px;"><span style="font-family: Menlo; font-size: 14px; color: rgb(0, 0, 0);"> end</span></p>
<p style="line-height: normal; margin: 0px;"><span style="font-family: Menlo; font-size: 14px; color: rgb(0, 0, 0);">end</span></p>
<p style="line-height: normal; margin: 0px; min-height: 16px;"><span style="font-family: Menlo; font-size: 14px; color: rgb(0, 0, 0);"><br>
</span></p>
<p style="line-height: normal; margin: 0px;"><span style="font-family: Menlo; font-size: 14px; color: rgb(0, 0, 0);">do list(path:tmp,var:c)</span></p>
<p style="line-height: normal; margin: 0px;"><span style="font-family: Menlo; font-size: 14px; color: rgb(0, 0, 0);"> if all_match(c,'^\(DE-627\).*')</span></p>
<p style="line-height: normal; margin: 0px;"><span style="font-family: Menlo; font-size: 14px; color: rgb(0, 0, 0);"> replace_all(c,'^\([^\)]+\)(.*)$','$1')</span></p>
<p style="line-height: normal; margin: 0px;"><span style="font-family: Menlo; font-size: 14px; color: rgb(0, 0, 0);"> copy_field(c,'relation\.journalppn.$append')</span></p>
<p style="line-height: normal; margin: 0px;"><span style="font-family: Menlo; font-size: 14px; color: rgb(0, 0, 0);"> end</span></p>
<p style="line-height: normal; margin: 0px; min-height: 16px;"><span style="font-family: Menlo; font-size: 14px; color: rgb(0, 0, 0);"><br>
</span></p>
<p style="line-height: normal; margin: 0px;"><span style="font-family: Menlo; font-size: 14px; color: rgb(0, 0, 0);"> if all_match(c,'^\(DE-600\).*')</span></p>
<p style="line-height: normal; margin: 0px;"><span style="font-family: Menlo; font-size: 14px; color: rgb(0, 0, 0);"> replace_all(c,'^\([^\)]+\)(.*)$','$1')</span></p>
<p style="line-height: normal; margin: 0px;"><span style="font-family: Menlo; font-size: 14px; color: rgb(0, 0, 0);"> copy_field(c,'relation\.journalzdbid.$append')</span></p>
<p style="line-height: normal; margin: 0px;"><span style="font-family: Menlo; font-size: 14px; color: rgb(0, 0, 0);"> end</span></p>
<p style="line-height: normal; margin: 0px;"><span style="font-family: Menlo; font-size: 14px; color: rgb(0, 0, 0);">end </span></p>
<p style="line-height: normal; margin: 0px; min-height: 16px;"><span style="font-family: Menlo; font-size: 14px; color: rgb(0, 0, 0);"><br>
</span></p>
<p style="line-height: normal; margin: 0px;"><span style="font-family: Menlo; font-size: 14px; color: rgb(0, 0, 0);">join_field('relation\.journalppn','|')</span></p>
<p style="line-height: normal; margin: 0px;"><span style="font-family: Menlo; font-size: 14px; color: rgb(0, 0, 0);">join_field('relation\.journalzdbid','|')</span></p>
<p style="line-height: normal; margin: 0px; min-height: 16px;"><span style="font-family: Menlo; font-size: 14px; color: rgb(0, 0, 0);"><br>
</span></p>
<p class="elementToProof" style="line-height: normal; margin: 0px;"><span style="font-family: Menlo; font-size: 14px; color: rgb(0, 0, 0);">remove_field(tmp)</span></p>
<p class="elementToProof" style="line-height: normal; margin: 0px;"><span style="font-family: Menlo; font-size: 14px; color: rgb(0, 0, 0);"><br>
</span></p>
<p class="elementToProof" style="line-height: normal; margin: 0px;"><span style="letter-spacing: normal; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 16px; font-weight: 400; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">BR</span></p>
<p class="elementToProof" style="line-height: normal; margin: 0px;"><span style="letter-spacing: normal; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 16px; font-weight: 400; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">Patrick</span></p>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> librecat-dev-bounces@lists.uni-bielefeld.de <librecat-dev-bounces@lists.uni-bielefeld.de> on behalf of Hemme, Felix <f.hemme@zbw-online.eu><br>
<b>Sent:</b> 17 November 2023 14:10<br>
<b>To:</b> librecat-dev@lists.uni-bielefeld.de <librecat-dev@lists.uni-bielefeld.de><br>
<b>Subject:</b> [librecat-dev] Catmandu copy field and operate on it, replacing and extracting stuff</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">Hi Catmandu users, (sorry for a longer email),<br>
<br>
I'm working on a MARC record containing 773 fields like this:<br>
<br>
<datafield tag="773" ind1="0" ind2="8"><br>
<subfield code="i">Enthalten in</subfield><br>
<subfield code="t">Athens journal of business & economics</subfield><br>
<subfield code="d">Athens : Business & Law Research Division and the<br>
Economics Research Unit of ATINER, 2015</subfield><br>
<subfield code="d">Athens : Business & Law Research Division and the<br>
Economics Research Unit of ATINER, 2015</subfield><br>
<subfield code="g">6(2020), 2 vom: Apr., Seite 127-144</subfield><br>
<subfield code="h">Online-Ressource</subfield><br>
<subfield code="h">Online-Ressource</subfield><br>
<subfield code="w">(DE-627)85561451X</subfield><br>
<subfield code="w">(DE-600)2851008-2</subfield><br>
<subfield code="w">(DE-576)462896099</subfield><br>
<subfield code="x">2241-794X</subfield><br>
<subfield code="7">nnns</subfield><br>
</datafield><br>
<br>
I want to map the values from $w to multiple fields, depending of the source<br>
of the ID that is specified in parentheses, e.g. (DE-627) = K10plus union<br>
catalog and (DE-600) = ZDB. <br>
<br>
Here is what I've done in a fix file to filter for those ID's:<br>
<br>
# Journal PPN id<br>
# only for target owc-de-206 and nl-zeitschriften<br>
do marc_each()<br>
if all_match('target','owc-de-206')<br>
if marc_any_match('7737|||s','s')<br>
if marc_any_match('773w','(DE-627)')<br>
marc_copy('773w','773wFixed2')<br>
marc_replace_all('773wFixed2','^((?!DE-627).)*$','')<br>
<br>
marc_replace_all('773wFixed2','^(\(DE-627\))(\d{8,9}[\dxX]{1}$)','$2')<br>
marc_map('773wFixed2','relation\.journalppn.$append')<br>
end<br>
end<br>
end<br>
end<br>
join_field('relation\.journalppn','|')<br>
<br>
This condition is working and extracts the value "85561451X". In order to<br>
not delete all 773's that don't match the given Regex, I copied the content<br>
to a tmp field "773wFixed1" and operate on it. The next part won't extract<br>
anything and I don't know why:<br>
<br>
# ZDB id for journals<br>
do marc_each()<br>
if marc_any_match('7737|||s','s')<br>
if marc_any_match('773w','(DE-600)')<br>
marc_copy('773w','773wFixed3')<br>
marc_replace_all('773wFixed3','^((?!DE-600).)*$','')<br>
#marc_replace_all('773wFixed3','^(\(DE-600\))(\d{7}-[\dxX]{1}$)','$2')<br>
marc_map('773wFixed3','relation\.journalzdbid.$append')<br>
end<br>
end<br>
end<br>
join_field('relation\.journalzdbid','|')<br>
<br>
It should extract the value 2851008-2. <br>
<br>
Happy for any advice you might have. Felix<br>
<br>
Best regards,<br>
Felix Hemme<br>
..........................................<br>
People's gender identity cannot be reliably deduced from either their<br>
appearance or their name. Let me know how you would like to be addressed.<br>
<br>
FELIX HEMME<br>
Metadata Management<br>
Pronouns: he/him<br>
<br>
ZBW - Leibniz Information Centre for Economics<br>
Duesternbrooker Weg 120<br>
24105 Kiel<br>
Germany<br>
T: +49 431 8814-355<br>
E: f.hemme@zbw-online.eu <br>
*Due to the change of our e-mail system you can currently reach me via this<br>
e-mail address.<br>
<br>
<br>
<br>
_______________________________________________<br>
librecat-dev mailing list<br>
- send list mails to librecat-dev@lists.uni-bielefeld.de<br>
- to unsubscribe or change options, visit <a href="https://lists.uni-bielefeld.de/mailman2/cgi/unibi/listinfo/librecat-dev">
https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.uni-bielefeld.de%2Fmailman2%2Fcgi%2Funibi%2Flistinfo%2Flibrecat-dev&data=05%7C01%7CPatrick.Hochstenbach%40UGent.be%7C9b85275ed5e74758d00508dbe76ec70b%7Cd7811cdeecef496c8f91a1786241b99c%7C1%7C0%7C638358235198507411%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=CTzgipu635INGHiBlI4hqt2uLVAdb2dyuMt7h%2F2yI1I%3D&reserved=0</a><br>
- project website: <a href="http://librecat.org/">https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Flibrecat.org%2F&data=05%7C01%7CPatrick.Hochstenbach%40UGent.be%7C9b85275ed5e74758d00508dbe76ec70b%7Cd7811cdeecef496c8f91a1786241b99c%7C1%7C0%7C638358235198507411%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=Ok9%2FRQtlu1Z%2B9RRw8MKl9%2F8b6m03a2irchuDLNfo5Zk%3D&reserved=0</a><br>
</div>
</span></font></div>
</body>
</html>