<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none"><!-- p { margin-top: 0px; margin-bottom: 0px; }--></style>
</head>
<body dir="ltr" style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<p>With Catmandu::MARC 1.231 you can do this to get a list of all record id and authority tags:<br>
</p>
<p><br>
</p>
<p>$ catmandu convert MARC --type RAW to JSON --fix auth.fix < auth_test_links.mrc<br>
</p>
<p>[{"_id":"59de6bd221c0c8f86d4863f9","heading":"200"}]<br>
</p>
<p><br>
</p>
<p>with `auth.fix` as:<br>
</p>
<p><br>
</p>
<div>marc_map(001,_id)</div>
<div><br>
</div>
<div>do marc_each(var:this)</div>
<div>  if all_match(this.tag,"^2..")</div>
<div>    copy_field(this.tag,heading)</div>
<div>  end</div>
<div>end</div>
<div><br>
</div>
<div>retain(_id,heading)<br>
</div>
<div><br>
</div>
<div>You could store this list for instance in a SQLLite database to use to the authority identifiers in lookups:<br>
</div>
<div><br>
</div>
<div><span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);">$ catmandu import </span><span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);">MARC
 --type RAW </span><span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);">to DBI --data_source dbi:SQLite:auth.sqlite < auth_test_links.mr</span><span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);">c</span><br>
</div>
<p><br>
</p>
<p>You can use this SQLLite database to create for instance a TSV file with all matching $3 links to authority records (use Null to supress the normal output and use exporters inside the fix script)<br>
</p>
<p><br>
</p>
<p>$ catmandu convert MARC --type RAW to Null --fix lookup.fix < bib_test_links.mrc<br>
</p>
<div>00id<span style="white-space:pre"> </span>01tag<span style="white-space:pre">
</span>02auth_id<span style="white-space:pre"> </span>03heading</div>
<div>59de80bc21c0c8f86d4b9e6e<span style="white-space:pre"> </span>606<span style="white-space:pre">
</span>59de6bd221c0c8f86d4863f9<span style="white-space:pre"> </span>200</div>
<div>59de80bc21c0c8f86d4b9e6e<span style="white-space:pre"> </span>606<span style="white-space:pre">
</span>59de6bd221c0c8f86d48f223<span style="white-space:pre"> </span>NOT FOUND</div>
<div>59de80bc21c0c8f86d4b9e6e<span style="white-space:pre"> </span>701<span style="white-space:pre">
</span>59de6bd221c0c8f86d48595e<span style="white-space:pre"> </span>NOT FOUND</div>
<div>59de80bc21c0c8f86d4b9e6e<span style="white-space:pre"> </span>712<span style="white-space:pre">
</span>59de6bd321c0c8f86d4944ca<span style="white-space:pre"> </span>NOT FOUND<br>
</div>
<div><br>
</div>
<div>With `lookup.fix` as:<br>
</div>
<div><br>
</div>
<div>
<div>marc_map(001,_id)<br>
</div>
<div><br>
</div>
<div>do marc_each(var:this)<br>
</div>
<div>    # Get every $3 subfield<br>
</div>
<div>    marc_map('***3',auth_id)</div>
<div><br>
</div>
<div>    # If there is an $3 try to find it in the auth.sqlite database<br>
</div>
<div>    if exists(auth_id)</div>
<div>      lookup_in_store(auth_id,DBI, data_source: "dbi:SQLite:auth.sqlite")</div>
<div><br>
</div>
<div>      # Create a TSV output with 4 columns: id, tag, auth_id and the heading (if found)<br>
</div>
<div>      copy_field(_id,output.00id)</div>
<div>      copy_field(this.tag,output.01tag)</div>
<div><br>
</div>
<div>      if exists(auth_id.heading)</div>
<div>        copy_field(auth_id._id,output.02auth_id)</div>
<div>        copy_field(auth_id.heading,output.03heading)</div>
<div>      else</div>
<div>        copy_field(auth_id,output.02auth_id)</div>
<div>        add_field(output.03heading,"NOT FOUND")</div>
<div>      end</div>
<div><br>
</div>
<div>      add_to_exporter(output,TSV)</div>
<div><br>
</div>
<div>      remove_field(auth_id)</div>
<div>      remove_field(output)</div>
<div>    end</div>
<div>end</div>
<div><br>
</div>
<div>retain(_id,auth_id)<br>
</div>
<br>
</div>
<div>Probably you want to process this TSV file further to find mistakes in the $3 -> authority tag but this shouldn't be hard now.<br>
</div>
<div><br>
</div>
<div>I'm now off to my Christmas diners. Good luck and until 2018.<br>
</div>
<p><br>
</p>
<div style="color: rgb(33, 33, 33);">
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> librecat-dev-bounces@lists.uni-bielefeld.de <librecat-dev-bounces@lists.uni-bielefeld.de> on behalf of Spiros Antonio <spiros.antonio@gmail.com><br>
<b>Sent:</b> Friday, December 22, 2017 8:33 AM<br>
<b>To:</b> librecat-dev@lists.uni-bielefeld.de<br>
<b>Subject:</b> [librecat-dev] Catmandu get headings tag</font>
<div> </div>
</div>
<div>
<div dir="ltr">Hello,
<div><br>
</div>
<div>i need to use a catmandu fix in my code, in order to be able to get the headings tag </div>
<div><br>
</div>
<div>out of a given authorities file.</div>
<div><br>
</div>
<div>In our case, the headings tag in each authority record is a 2.. (2xx) tag</div>
<div><br>
</div>
<div>Only one 2xx tag exists in each authority record.</div>
<div><br>
</div>
<div>I know how i could get the 2xx value, but in this case i need to know the tag value,</div>
<div><br>
</div>
<div>thank you</div>
<div><br>
</div>
</div>
</div>
</div>
</body>
</html>