Re: identify ISSN numbers in an mrc file
[email protected] (Sergio Letuche) Wed, 2 Nov 2016 12:06:15 +0200
| Newsgroups | perl.perl4lib |
|---|---|
| Message-ID | <CANnh_k90W0moYG2nipSSsA1J61c7uc5zSRTwN75ir9QBRUH8qA@mail.gmail.com> |
--94eb2c19e11c7a11cd05404e9711 Content-Type: text/plain; charset=UTF-8 Thank you dear Stefano, i am aware of this module, it works great. But my problem is, what clever regex to use, in order to identify if a subfield's content, is an ISSN number. Say our mrc has ISSN numbers thrown in any tag you could imagine... So my approach, would be, to search the whole mrc, but i do non know which regex to use... 2016-11-02 11:52 GMT+02:00 Stefano Bargioni <[email protected]>: > Hi, Sergio: > you can try MARCgrep http://en.pusc.it/bib/MARCgrep. > Its help is: > > MARCgrep.pl > Extracts MARC records that match a condition on fields. Count and > invert are available. > > SYNOPSIS > MARCgrep.pl [options] [-e condition] file.mrc > > Options: > -h print this help message and exit > -c count only > -e condition > -f comma separated list of fields to print > -o output format "marc" | "line" | "INLINE" > -s separator string for condition, default "," > -v invert match > > Condition: > -e 'tag,indicator1,indicator2,subfield,value' > > OPTIONS > -h Print this message and exit. > > -c Count and print number of matching records > > -e The condition to match in the record. > For data fields, the syntax is: > > tag,indicator1,indicator2,subfield,value > > where tag, indicator1, indicator2, subfield, and value are > regular expressions patterns. > Do not put spaces around the separators. > > For control fields, the syntax is: > > tag,pos1,pos2,value > > where tag starts with '00' (use '000' or 'LDR' for > leader), pos1 is the starting position, > pos2 is the ending position, both 0-based. Value is a > regular expression. > > Default condition (-e not specified) matches any data > field. > For control fields, only the tag is mandatory. > > Examples: -e '100,,,a,^A' will match records that contain > 100$a starting with 'A' > -e '008,35,37,(ita|eng)' will match records with > language ita or eng in 008 > -e '(1|7)(0|1)(0|1),,2' will match > 100,110,111,700,710,711 with ind2=2 > > -f Comma separated list of fields (tags) to print if output > format > is "line" or "inline". Default is any field. > Note that if a tag is preceded by '#' sign (like in > '#nnn'), a > count of occurrences will be printed instead. > > Examples: -f '100,245' will print field 100 and 245 > -f '400,#400' will print all occurrences of 400 > field as well as the number of its occurrences > > -o Output format: "marc" for ISO2709, "line" for each subfield > in > a line, "inline" (default) for each field in a line. > > -s Specify a string separator for condition. Default is ','. > > -v Invert the sense of matching, to select non-matching > records. > > -V Print the version and exit. > > file.mrc > The mandatory ISO2709 file to read. Can be STDIN, '-'. > > DESCRIPTION > Like grep, the famous Unix utility, MARCgrep.pl allows to filter > MARC > bibliographic > records based on conditions on tag, indicators, and field value. > > Conditions can be applied to data fields, control fields or the > leader. > > In case of data fields, the condition can specify tag, indicators, > subfield and value using regular > expressions. In case of control fields, the condition must contain > the > tag name, the starting > and ending position (both 0-based), and a regular expressions for > the > value. > > Options -c and -v allow respectively to count matching records and > to > invert the match. > > If option -c is not specified, the output format can be "line" or > "inline" (both human readable), > or "marc" for MARC binary (ISO2709). For formats "line" or > "inline", > the -f option allows to specify > fields to print. > > You can chain more conditions using > > ./MARCGgrep.pl -o marc -e condition1 file.mrc | ./MARCGgrep.pl -e > condition2 - > > KNOWN ISSUES > Performance. > > Accepts and returns only UTF-8. > > Checks are case sensitive. > > AUTHOR > Pontificia Universita' della Santa Croce <http://www.pusc.it/bib/> > > Stefano Bargioni <[email protected]> > > SEE ALSO > marktriggs / marcgrep at <https://github.com/marktriggs/marcgrep> > for > filtering large data sets > > > > On 02 nov 2016, at 09:57, Sergio Letuche <[email protected]> > wrote: > > > > Hello community, > > > > how would you treat the following? > > > > I need a way to identify all tags - subfields, that have stored an ISSN > number in them. > > > > What would you suggest as a clever approach for this? > > > > Thank you > > --94eb2c19e11c7a11cd05404e9711 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr">Thank you dear Stefano,<div><br></div><div>i am aware of t= his module, it works great.</div><div><br></div><div>But my problem is, wha= t clever regex to use, in order to identify if a subfield's content, is= an ISSN number. Say our mrc has ISSN numbers thrown in any tag you could i= magine...</div><div><br></div><div>So my approach, would be, to search the = whole mrc, but i do non know which regex to use...=C2=A0</div></div><div cl= ass=3D"gmail_extra"><br><div class=3D"gmail_quote">2016-11-02 11:52 GMT+02:= 00 Stefano Bargioni <span dir=3D"ltr"><<a href=3D"mailto:[email protected]= t" target=3D"_blank">[email protected]</a>></span>:<br><blockquote class= =3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padd= ing-left:1ex">Hi, Sergio:<br> you can try MARCgrep <a href=3D"http://en.pusc.it/bib/MARCgrep" rel=3D"nore= ferrer" target=3D"_blank">http://en.pusc.it/bib/MARCgrep</a><wbr>.<br> Its help is:<br> <br> MARCgrep.pl<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0Extracts MARC records that match a condition on = fields. Count and<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0invert are available.<br> <br> SYNOPSIS<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0MARCgrep.pl [options] [-e condition] file.mrc<br= > <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 Options:<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 -h=C2=A0 =C2=A0print this help message a= nd exit<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 -c=C2=A0 =C2=A0count only<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 -e=C2=A0 =C2=A0condition<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 -f=C2=A0 =C2=A0comma separated list of f= ields to print<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 -o=C2=A0 =C2=A0output format "marc&= quot; | "line" | "INLINE"<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 -s=C2=A0 =C2=A0separator string for cond= ition, default ","<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 -v=C2=A0 =C2=A0invert match<br> <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 Condition:<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 -e=C2=A0 'tag,indicator1,indicator2,= <wbr>subfield,value'<br> <br> OPTIONS<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0-h=C2=A0 =C2=A0 =C2=A0 Print this message and ex= it.<br> <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0-c=C2=A0 =C2=A0 =C2=A0 Count and print number of= matching records<br> <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0-e=C2=A0 =C2=A0 =C2=A0 The condition to match in= the record.<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 For data fields, th= e syntax is:<br> <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 tag,indicato= r1,indicator2,<wbr>subfield,value<br> <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 where tag, indicato= r1, indicator2, subfield, and value are regular expressions patterns.<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Do not put spaces a= round the separators.<br> <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 For control fields,= the syntax is:<br> <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 tag,pos1,pos= 2,value<br> <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 where tag starts wi= th '00' (use '000' or 'LDR' for leader), pos1 is th= e starting position,<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 pos2 is the ending = position, both 0-based. Value is a regular expression.<br> <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Default condition (= -e not specified) matches any data field.<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 For control fields,= only the tag is mandatory.<br> <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Examples: -e '1= 00,,,a,^A' will match records that contain 100$a starting with 'A&#= 39;<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 -e '008,35,37,(ita|eng)' will match records with = language ita or eng in 008<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 -e '(1|7)(0|1)(0|1),,2' will match 100,110,111,70= 0,710,711 with ind2=3D2<br> <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0-f=C2=A0 =C2=A0 =C2=A0 Comma separated list of f= ields (tags) to print if output format<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0is "line" = or "inline". Default is any field.<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Note that if a tag = is preceded by '#' sign (like in '#nnn'), a<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0count of occurrences= will be printed instead.<br> <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Examples: -f '1= 00,245' will print field 100 and 245<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 -f '400,#400' will print all occurrences of 400 f= ield as well as the number of its occurrences<br> <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0-o=C2=A0 =C2=A0 =C2=A0 Output format: "marc= " for ISO2709, "line" for each subfield in<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0a line, "inline= " (default) for each field in a line.<br> <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0-s=C2=A0 =C2=A0 =C2=A0 Specify a string separato= r for condition. Default is ','.<br> <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0-v=C2=A0 =C2=A0 =C2=A0 Invert the sense of match= ing, to select non-matching records.<br> <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0-V=C2=A0 =C2=A0 =C2=A0 Print the version and exi= t.<br> <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0file.mrc<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0The mandatory ISO270= 9 file to read. Can be STDIN, '-'.<br> <br> DESCRIPTION<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0Like grep, the famous Unix utility, MARCgrep.pl = allows to filter MARC<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0bibliographic<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 records based on conditions on tag, indicators,= and field value.<br> <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0Conditions can be applied to data fields, contro= l fields or the leader.<br> <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0In case of data fields, the condition can specif= y tag, indicators,<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0subfield and value using regular<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 expressions. In case of control fields, the con= dition must contain the<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0tag name, the starting<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 and ending position (both 0-based), and a regul= ar expressions for the<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0value.<br> <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0Options -c and -v allow respectively to count ma= tching records and to<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0invert the match.<br> <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0If option -c is not specified, the output format= can be "line" or<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0"inline" (both human readable),<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 or "marc" for MARC binary (ISO2709). = For formats "line" or "inline",<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0the -f option allows to specify<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 fields to print.<br> <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0You can chain more conditions using<br> <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0./MARCGgrep.pl -o marc -e condition1 file.mrc | = ./MARCGgrep.pl -e<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0condition2 -<br> <br> KNOWN ISSUES<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0Performance.<br> <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0Accepts and returns only UTF-8.<br> <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0Checks are case sensitive.<br> <br> AUTHOR<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0Pontificia Universita' della Santa Croce <= ;<a href=3D"http://www.pusc.it/bib/" rel=3D"noreferrer" target=3D"_blank">h= ttp://www.pusc.it/bib/</a>><br> <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0Stefano Bargioni <<a href=3D"mailto:bargioni@= pusc.it">[email protected]</a>><br> <br> SEE ALSO<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0marktriggs / marcgrep at <<a href=3D"https://= github.com/marktriggs/marcgrep" rel=3D"noreferrer" target=3D"_blank">https:= //github.com/<wbr>marktriggs/marcgrep</a>> for<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0filtering large data sets<br> <div class=3D"HOEnZb"><div class=3D"h5"><br> <br> > On 02 nov 2016, at 09:57, Sergio Letuche <<a href=3D"mailto:code4li= [email protected]">[email protected]</a>> wrote:<br> ><br> > Hello community,<br> ><br> > how would you treat the following?<br> ><br> > I need a way to identify all tags - subfields, that have stored an ISS= N number in them.<br> ><br> > What would you suggest as a clever approach for this?<br> ><br> > Thank you<br> <br> </div></div></blockquote></div><br></div> --94eb2c19e11c7a11cd05404e9711--