[librecat-dev] Catmandu marc questions

Lars Kolling lars.kollingl at gmail.com
Sat Sep 10 15:01:55 CEST 2016


Dear Johann,

i want to thank you very very much for this thorough answer.
only a small clarification

catmandu convert --fix 'retain(_id)' MARC to YAML < file_0.mrc

i noticed that something like catmandu convert --fix 'retain(_id)' MARC to
Text < file_0.mrc

gives me the result i need,

for example only the text values of the 001 field.


My question was not related to the input and output mrc files, but to a
single mrc file.

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.

Best




On Sat, Sep 10, 2016 at 2:58 PM, Johann Rolschewski <rolschewski at gmail.com>
wrote:

> Hi Lars,
>
> > 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?
>
> you can use lookup tables as Patrick described in one of his last posts:
>
> 1. Create CSV files
>
> names.csv:
>
> oldname,newname
> name1a,name1b
> name2a,name2b
> name3a,name3b
>
> titles.csv:
>
> oldtitle,newtitle
> title1a,title1b
> title2a,title2b
> title3a,title3b
>
> 2. Create a fix file
>
> replace.fix:
>
> do marc_each()
>     marc_map(100a,tmp.name);
>     lookup(tmp.name,names.csv,delete:1)
>     if exists(tmp.name)
>         marc_set(100a,$.tmp.name)
>         remove_field(tmp.name)
>     end
>     marc_map(245a,tmp.title);
>     lookup(tmp.title,titles.csv,delete:1)
>     if exists(tmp.title)
>         marc_set(245a,$.tmp.title)
>         remove_field(tmp.title)
>     end
>     remove_field(tmp)
> end
>
> 3. Run conversion
>
> $ catmandu convert MARC to MARC --fix replace.fix < input.mrc > output.mrc
>
> > last, i do not know how to produce a clean report,
> > say i wanted to have a txt file with all 001 values, or a tag that is
> repeatable....
> >
> > i noticed
> >
> > catmandu convert --fix 'retain(_id)' MARC to YAML < file_0.mrc
> >
> > has an output that adds for example ' character, when we have a digit
> >
> > ---
> > _id: '120090304134844'
> > ...
> > ---
> > _id: recorda
> > ...
> > ---
> > _id: recordb
> > ...
> > ---
> > _id: recordc
> > ...
> > ---
> > _id: recorde
> > ...
> > ---
> > _id: '8797989999140813'
> >
> > Is there a way to have just the values, in a row by row format?
>
> I don't know any possibility to generate a CSV report while doing a MARC
> to MARC conversion with Catmandu. You could use another fix and generate
> CSV reports for the input and output and join them afterwards.
>
> 4. Create a fix file:
>
> report.fix:
>
> marc_map(100a,name)
> marc_map(245a,title)
>
> 5. Run conversions:
>
> $ catmandu convert MARC to CSV --fix report.fix --fields _id,name,title
> < input.mrc > input.csv
>
> $ catmandu convert MARC to CSV --fix report.fix --fields _id,name,title
> < output.mrc > output.csv
>
> 6. Generate report:
>
> $ join -t , input.csv output.csv > report.csv
>
>
> Johann
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.uni-bielefeld.de/mailman2/unibi/public/librecat-dev/attachments/20160910/a5769f72/attachment.html>


More information about the librecat-dev mailing list