<div dir="ltr"><div>Dear Johann,</div><div><br></div>i want to thank you very very much for this thorough answer.<br>only a small clarification<br><br>catmandu convert --fix 'retain(_id)' MARC to YAML < file_0.mrc<br><br>i noticed that something like catmandu convert --fix 'retain(_id)' MARC to Text < file_0.mrc<br><br>gives me the result i need,<br><br>for example only the text values of the 001 field.<br><br><br>My question was not related to the input and output mrc files, but to a single mrc file.<br><br>How one can have as a txt output all occurrences (values found) of say the 001 tag, or even better, a repeatable tag/subfield, in a row by row txt file.<br><br>Best<br><div><span style="color:rgb(80,0,80);font-size:12.8px"> </span></div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Sep 10, 2016 at 2:58 PM, Johann Rolschewski <span dir="ltr"><<a href="mailto:rolschewski@gmail.com" target="_blank">rolschewski@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Lars,<br>
<br>
> The example provided by /Johann,/ instead of doing the below, how one could give as input a txt file named OldNames.csv and the replacements be in a file named NewNames.csv?<br>
<br>
you can use lookup tables as Patrick described in one of his last posts:<br>
<br>
1. Create CSV files<br>
<br>
names.csv:<br>
<br>
oldname,newname<br>
name1a,name1b<br>
name2a,name2b<br>
name3a,name3b<br>
<br>
titles.csv:<br>
<br>
oldtitle,newtitle<br>
title1a,title1b<br>
title2a,title2b<br>
title3a,title3b<br>
<br>
2. Create a fix file<br>
<br>
replace.fix:<br>
<br>
do marc_each()<br>
    marc_map(100a,<a href="http://tmp.name" rel="noreferrer" target="_blank">tmp.name</a>);<br>
    lookup(<a href="http://tmp.name" rel="noreferrer" target="_blank">tmp.name</a>,names.csv,<wbr>delete:1)<br>
    if exists(<a href="http://tmp.name" rel="noreferrer" target="_blank">tmp.name</a>)<br>
        marc_set(100a,$.<a href="http://tmp.name" rel="noreferrer" target="_blank">tmp.name</a>)<br>
        remove_field(<a href="http://tmp.name" rel="noreferrer" target="_blank">tmp.name</a>)<br>
    end<br>
    marc_map(245a,tmp.title);<br>
    lookup(tmp.title,titles.csv,<wbr>delete:1)<br>
    if exists(tmp.title)<br>
        marc_set(245a,$.tmp.title)<br>
        remove_field(tmp.title)<br>
    end<br>
    remove_field(tmp)<br>
end<br>
<br>
3. Run conversion<br>
<br>
$ catmandu convert MARC to MARC --fix replace.fix < input.mrc > output.mrc<br>
<span class=""><br>
> last, i do not know how to produce a clean report,<br>
> say i wanted to have a txt file with all 001 values, or a tag that is repeatable....<br>
><br>
> i noticed<br>
><br>
> catmandu convert --fix 'retain(_id)' MARC to YAML < file_0.mrc<br>
><br>
> has an output that adds for example ' character, when we have a digit<br>
><br>
> ---<br>
> _id: '120090304134844'<br>
> ...<br>
> ---<br>
> _id: recorda<br>
> ...<br>
> ---<br>
> _id: recordb<br>
> ...<br>
> ---<br>
> _id: recordc<br>
> ...<br>
> ---<br>
> _id: recorde<br>
> ...<br>
> ---<br>
> _id: '8797989999140813'<br>
><br>
> Is there a way to have just the values, in a row by row format?<br>
<br>
</span>I don't know any possibility to generate a CSV report while doing a MARC<br>
to MARC conversion with Catmandu. You could use another fix and generate<br>
CSV reports for the input and output and join them afterwards.<br>
<br>
4. Create a fix file:<br>
<br>
report.fix:<br>
<br>
marc_map(100a,name)<br>
marc_map(245a,title)<br>
<br>
5. Run conversions:<br>
<br>
$ catmandu convert MARC to CSV --fix report.fix --fields _id,name,title<br>
< input.mrc > input.csv<br>
<br>
$ catmandu convert MARC to CSV --fix report.fix --fields _id,name,title<br>
< output.mrc > output.csv<br>
<br>
6. Generate report:<br>
<br>
$ join -t , input.csv output.csv > report.csv<br>
<span class="HOEnZb"><font color="#888888"><br>
<br>
Johann<br>
<br>
</font></span></blockquote></div><br></div>