Skip to content

Instantly share code, notes, and snippets.

@miku
Last active November 24, 2016 12:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miku/c8288adbdb2393a55673c86af91a3427 to your computer and use it in GitHub Desktop.
Save miku/c8288adbdb2393a55673c86af91a3427 to your computer and use it in GitHub Desktop.
MARC field distribution
01571cas a22003611a 45 001001200000005001700012008004100029010003600070022001400106032001700120035001600137037006600153040012800219049001700347050001800364210002700382222004000409245010200449246004000551260004500591300002700636310001900663362005700682500002200739500006900761515003100830650004900861650003600910650003200946710006000978780006301038785010801101testsample120091117105557.0840328d19831987nyufx1p o 0 a0eng d a 84643014 //r88zsn 84011556 0 a0748-1985 a002051bUSPS aocm10569413 bHuman Sciences Press, Inc., 72 5th Ave., New York, N.Y. 10011 aKSWcKSWdCLUdAIPdNSTdDLCdNSDdNSTdDLCdHULdNSTdNSDdNLMdNSTdNSDdNSTdNSDdDLCdNSTdNSDdNSTdCLUdNSTdOCLdPVU aPVUP[SERIAL]00aAC489.R3bJ680 aJ. ration. emot. ther. 0aJournal of rational emotive therapy00aJournal of rational emotive therapy :bthe journal of the Institute for Rational-Emotive Therapy.13aJournal of rational-emotive therapy a[New York] :bThe Institute,c1983-1987. a5 v. :bill. ;c26 cm. aTwo no. a year0 aVol. 1, no. 1 (fall 1983)-v. 5, no. 4 (winter 1987). aTitle from cover. aVols. for <spring 1985-> published by Human Sciences Press, Inc. aVol. 1 has only one issue. 0aRational-emotive psychotherapyvPeriodicals. 0aCognitive therapyvPeriodicals. 2aPsychotherapyvperiodicals.2 aInstitute for Rational-Emotive Therapy (New York, N.Y.)00tRational livingx0034-0049w(OCLC)1763461w(DLC) 7200064700tJournal of rational-emotive and cognitive-behavior therapyx0894-9085w(DLC) 88648219w(OCoLC)1630781401195cas a22003011a 45 001001200000005001700012007001400029008004100043010002300084022001400107030001100121035001600132040008300148050001800231210001900249222002000268245002100288260004900309300002800358362005000386550005000436550013200486580006300618650003200681710006000713710003500773785008500808testsample220091117105643.0hd bfa b|c|751101d19661983nyufr1p 0 a0eng  a 72000647 //r8520 a0034-0049 aATLVBX aocm01763461 aDLCcMULdNSDdDLCdRCSdAIPdDLCdNSDdNSTdDLCdAIPdNSTdDLCdNSTdNSDdNST00aAA790.A1bR351 aRation. living 0aRational living00aRational living. a[New York] :bInstitute for Rational Living. a18 v. :bill. ;c27 cm.0 aVol. 1 (Feb. 1966)-v.18, no. 1 (spring 1983). aJournal of the Institute for Rational Living. aIssued by: Institute for Rational Living, Feb. 1966-spring 1982; Institute for Rational-Emotive Therapy, fall 1982-spring 1983. aContinued in 1983 by: Journal of rational emotive therapy. 0aMental healthvPeriodicals.2 aInstitute for Rational-Emotive Therapy (New York, N.Y.)2 aInstitute for Rational Living.10tJournal of rational emotive therapyx0748-1985w(DLC) 84643014w(OCoLC)1056941301057cas a22003011a 45 001001200000005001700012008004100029010003000070022001400100035001600114037005600130040003300186050002100219210002900240222003800269245003900307260004800346300002800394310001400422362003300436362004000469500002200509650003200531650003500563650004200598785009900640936001600739testsample320091117104735.0820311d19831998nyuqr1p o 0 a0eng d a 83-644252 zsn82-2030 0 a0731-7158 aocm08235783 bHaworth Press, 28 E. 22nd St., New York, N.Y. 10010 aNSDcNSDdDLCdAIPdNLMdNST0 aAC455.2.P73bP890 aPsychother. priv. pract. 0aPsychotherapy in private practice00aPsychotherapy in private practice. a[New York, N.Y.] :bHaworth Press,c[c1983- a17 v. :bill. ;c23 cm. aQuarterly0 aVol. 1, no. 1 (spring 1983)-1 aCeased with: Vol. 17, no. 4 (1998). aTitle from cover. 2aPsychotherapyvperiodicals. 2aPrivate Practicevperiodicals. 0aPsychotherapyxPracticevPeriodicals.00tJournal of psychotherapy in independent practicex1522-9580w(DLC)sn 98005091w(OCoLC)40524650 aSummer 198401361cas a22003611a 45 001001200000005001700012007001600029008004100045010001700086022001400103030001100117032001700128035001600145037005800161040006300219090001700282210002400299222004000323245004100363260003200404300001700436310001400453362003100467500002200498650006400520650003400584506006600618530004200684710002600726856009600752856011700848936003400965testsample420091117105437.0cr an ---uuuuu840713c19859999nyuqr1p 0 a0eng d asn 84006638 0 a0748-4518 aJQCRE6 a755730bUSPS aocm10945712 bPlenum Pub. Corp., 233 Spring St., New York, NY 10013 aNSDcNSDdFUGdNSDdNSTdIULdNSTdHULdNSTdEYMdNSTdHUL aAV6001b.J721 aJ. quant. criminol. 0aJournal of quantitative criminology00aJournal of quantitative criminology. aNew York :bPlenum,cc1985- av. ;c23 cm. aQuarterly0 aVol. 1, no. 1 (Mar. 1985)- aTitle from cover. 0aCriminal justice, Administration ofxResearchvPeriodicals. 0aCrimexResearchvPeriodicals. aElectronic access restricted to Villanova University patrons. aAlso available on the World Wide Web.2 aLINK (Online service)41zOnline version [v. 15 (1999)-present]uhttp://springerlink.metapress.com/link.asp?id=10258641zOff-campus accessuhttp://openurl.villanova.edu:9003/sfx_local?sid=sfx:e_collection&issn=0748-4518&genre=journal aVol. 1, no. 4 (Dec. 1985) LIC01707cas a22004091a 45 001001200000005001700012007001500029007001400044008004100058010002200099022001400121030001100135032001700146035001600163040007900179050001700258210002000275222003000295245003500325260004300360300002500403362002400428506006600452530004200518550008700560555004200647500010300689650004300792700003600835700003500871700004600906710004900952710003401001856012101035856011701156936002401273testsample520091117092424.0cr mn ---|||||hd bda b|c|750901c19379999ncuqr1p 0 a0eng d a 40012649 //r86 a0022-3387 aJPRPAU a281800bUSPS aocm01588544 aMULcMULdNSDdDLCdNSDdDLCdm.c.dRCSdAIPdNSDdAIPdOCLdDLCdm/cdNST00aAF1001b.J661 aJ. parapsychol. 0aJournal of parapsychology04aThe Journal of parapsychology. aDurham, N.C. :bDuke University Press. av. :bill. ;c23 cm.0 aVol. 1 (Mar. 1937)- aElectronic access restricted to Villanova University patrons. aAlso available on the World Wide Web. aIssued in cooperation with the Duke University Parapsychology Laboratory, 194 -50. aVols. 1-16, 1937-52, in v. 17, no. 3. aEditors: Mar. 1937-<Dec. 1938> J. B. Rhine, C. E. Stuart (with W. McDougall, Mar. 1937-Sept. 1938) 0aParapsychologyxResearchvPeriodicals.1 aMcDougall, William,d1871-1938.1 aStuart, Charles Edward,d1907-1 aRhine, J. B.q(Joseph Banks),d1895-1980.2 aDuke University.bParapsychology Laboratory.2 aProQuest Psychology Journals.41zOnline version [v. 59 (1995)-present]uhttp://proquest.umi.com/pqdweb?pmid=000029287&clientId=3260&RQT=318&VName=PQD41zOff-campus accessuhttp://openurl.villanova.edu:9003/sfx_local?sid=sfx:e_collection&issn=0022-3387&genre=journal aMar. 1937-Dec. 195801532cas a22003371a 45 001001200000005001700012008004100029010003700070022001400107035001600121040003800137041002300175050001500198222004100213245004200254260010900296300002000405310002500425321002200450362005700472500002200529546004100551550017300592580007100765650003800836650003000874710004700904710007500951780008101026785008701107testsample620091117105533.0751101d19571970inumr1p o0 a0eng  aa 53008626 //r853zsc 80001624  a0095-9057 aocm01772601 aDLCcMULdNSDdDLCdm/cdHULdNST0 aengafreageraita0 aAA1b.J975 0aJournal of mathematics and mechanics00aJournal of mathematics and mechanics. aBloomington, Ind. :bGraduate Institute for Mathematics and Mechanics, Indiana University,cc1957-c1970. a14 v. ;c26 cm. aMonthly,b-June 1970 aBimonthly,b1957-0 aVol. 6, no. 1 (Jan. 1957)-v. 19, no. 12 (June 1970). aTitle from cover. aEnglish, French, German and Italian. aVols. for 1957- published by the Graduate Institute for Mathematics and Mechanics, Indiana University; -June 1970 by the Dept. of Mathematics, Indiana University. aContinued in July 1970 by: Indiana University mathematics journal. 0aMechanics, AnalyticvPeriodicals. 0aMathematicsvPeriodicals.2 aIndiana University.bDept. of Mathematics.2 aIndiana University.bGraduate Institute for Mathematics and Mechanics.00tJournal of rational mechanics and analysisw(DLC)sf 85001244w(OCoLC)226307110tIndiana University mathematics journalx0022-2518w(DLC) 75640369w(OCoLC)175301901426cas a22003851a 45 001001200000005001700012007001500029007001400044008004100058010001700099022001400116030001100130032001700141035001600158037006000174040005900234050001400293210001600307222003000323245003100353260004200384300002500426310002200451321002400473362002200497506006600519500004700585530004200632650002900674700003800703710003400741856012200775856011700897936002601014testsample720091117102216.0cr mn ---|||||hd bfa b|c|741112c19369999maubr1p 0 a0eng  a 38003075  a0022-3980 aJOPSAM a282400bUSPS aocm01782317 bJournal Press, 2 Commercial St., Provincetown, MA 02657 aDLCcDLCdOCLdDLCdNSDdm.c.dOCLdRCSdAIPdOCLdNSD00aAF1b.J671 aJ. psychol. 4aThe Journal of psychology04aThe Journal of psychology. aProvincetown, Mass. :bJournal Press. av. :bill. ;c25 cm. aBimonthly,b1965- aQuarterly,b1935-640 aVol. 1 (1935/36)- aElectronic access restricted to Villanova University patrons. aEditor: 1935/36-<Oct. 1937,> C. Murchison. aAlso available on the World Wide Web. 0aPsychologyvPeriodicals.1 aMurchison, Carl Allanmore,d1887-2 aProQuest Psychology Journals.41zOnline version [v. 128 (1994)-present]uhttp://proquest.umi.com/pqdweb?pmid=000014346&clientId=3260&RQT=318&VName=PQD41zOff-campus accessuhttp://openurl.villanova.edu:9003/sfx_local?sid=sfx:e_collection&issn=0022-3980&genre=journal aJan. 1975 (surrogate)01251cas a22003251a 45 001001200000005001700012007001500029008004100044010002200085022001400107030001100121035001600132040007300148050001400221210002300235222003800258245003900296260004200335300002500377362002400402506006600426500003000492530004200522650004100564650005200605700001800657710003600675856009700711856011700808testsample820091117102549.0cr an 741112c19569999enkbrzp 0 a0eng  a 57003141 //r830 a0022-3999 aJPCRAT aocm01782774 aDLCcDLCdNSDdOCLdNSDdDLCdSERdOCLdRCSdDLCdOCLdAIPdOCLdNSD00aAC52b.J61 aJ. psychosom. res. 0aJournal of psychosomatic research00aJournal of psychosomatic research. aLondon ;aNew York :bPergamon Press. av. :bill. ;c26 cm.0 aVol. 1 (Feb. 1956)- aElectronic access restricted to Villanova University patrons. aEditor: 1956- D. Leigh. aAlso available on the World Wide Web. 2aPsychosomatic Medicinevperiodicals. 0aMedicine, PsychosomaticxResearchvPeriodicals.1 aLeigh, Denis.2 aScienceDirect (Online service).41zOnline version [v. 44 (1998)-present]uhttp://www.sciencedirect.com/science/journal/0022399941zOff-campus accessuhttp://openurl.villanova.edu:9003/sfx_local?sid=sfx:e_collection&issn=0022-3999&genre=journal02173cas a2200469 a 4500001001200000005001700012006001900029007001500048008004100063010001700104035002300121040005000144022002800194037008800222050001300310049000900323130003700332210002600369222004200395245005600437260007000493310002800563321003600591362003100627500005200658500003300710500009500743506006600838538003600904550012000940650003701060650002201097650002901119710005101148710005701199710002501256776009601281780007501377856012201452856011701574994001201691testsample920091117160642.0m d cr mnu||||||||741112c19659999pauqx pss 0 a0eng d a 2006212058 a(OCoLC)ocm39109327 aFGAcFGAdOCLdOCLCQdFQMdNSDdEYMdHULdPVU0 a1559-8519y0022-449921 bSociety for the Scientific Study of Sexuality, PO Box 416, Allentown, PA 18105-041614aAQ5b.J6 aPVUM0 aJournal of sex research (Online)1 aJ. sex res.b(Online) 4aThe journal of sex researchb(Online)14aThe journal of sex researchh[electronic resource]. aNew York, N.Y. :bSociety for the Scientific Study of Sex,c1965- a4 issues yearly,b1967- aThree issues yearly,b1965-19660 aVol. 1, no. 1 (Mar. 1965)- aTitle from cover (JSTOR, viewed Apr. 18, 2007). aPlace of publication varies. aLatest issue consulted: Vol. 43, issue 4 (Nov. 2006) (SSSS website, viewed Apr. 18, 2007). aElectronic access restricted to Villanova University patrons. aMode of access: World Wide Web. aIssued by: Society for the Scientific Study of Sex, 1965-1994; Society for the Scientific Study of Sexuality, 1995- 0aSexologyxResearchvPeriodicals.12aSexvPeriodicals.22aPsychiatryvPeriodicals.2 aSociety for the Scientific Study of Sex (U.S.)2 aSociety for the Scientific Study of Sexuality (U.S.)2 aJSTOR (Organization)08iAlso issued in print:tJournal of sex researchx0022-4499w(DLC) 68130414w(OCoLC)178336500tAdvances in sex research (Online)w(DLC) 2007234124w(OCoLC)12320877540zOnline version [JSTOR: v. 1 (1965)-present ; latest 5 years unavailable]uhttp://www.jstor.org/journals/00224499.html40zOff-campus accessuhttp://openurl.villanova.edu:9003/sfx_local?sid=sfx:e_collection&issn=0022-4499&genre=journal aC0bPVU01195cas a22003251a 45 001001300000005001700013007001600030008004100046010001700087022001400104030001100118035001600129037001000145040005300155050001800208090001700226210002800243222004300271245004400314260005100358300001700409362002400426500003500450506006600485530004200551650004600593710002000639856009300659856011700752testsample1020091117093002.0cr bn ---|||||751002c19709999njufr1p 0 a0eng  a 75643076 0 a0047-2662 aJPHPAE aocm02240975 b07716 aDLCcDLCdNSDdDLCdOCLdRCSdAIPdNSDdOCLdNST0 aAF204.5b.J68 aAF204.5b.J61 aJ. phenomenol. psychol. 0aJournal of phenomenological psychology00aJournal of phenomenological psychology. a[Atlantic Highlands, N.J. :bHumanities Press] av. ;c23 cm.0 aVol. 1 (fall 1970)- aAt head of title <1974->: JPP. aElectronic access restricted to Villanova University patrons. aAlso available on the World Wide Web. 0aPhenomenological psychologyvPeriodicals.2 aIngenta (Firm).41zOnline version [v. 1 (1970/71)-present]uhttp://www.ingentaconnect.com/content/brill/jpp41zOff-campus accessuhttp://openurl.villanova.edu:9003/sfx_local?sid=sfx:e_collection&issn=0047-2662&genre=journal
#!/usr/bin/env python
# coding: utf-8
"""
Install pymarc first (https://github.com/edsu/pymarc):
$ pip install pymarc
Examples:
$ python marcstats.py journals.mrc
total 10 100%
040.d 105 1050.0% NSD [21], NST [20], DLC [16] ...
650.v 19 190.0% Periodicals. [15], periodicals. [4] ...
650.a 19 190.0% Psychotherapy [3], Mental health [1], Sex [1] ...
710.a 14 140.0% Institute for Ration [2], Indiana University. [2], ProQuest Psychology [2] ...
856.z 12 120.0% Off-campus access [6], Online version [v. 1 [1], Online version [JSTO [1] ...
500.a 12 120.0% Title from cover. [4], Editors: Mar. 1937-< [1], Editor: 1935/36-<Oct [1] ...
856.u 12 120.0% http://openurl.villa [1], http://www.ingentaco [1], http://www.sciencedi [1] ...
362.a 11 110.0% Vol. 1 (Mar. 1937)- [1], Ceased with: Vol. 17 [1], Vol. 1, no. 1 (Mar. [1] ...
260.a 11 110.0% New York : [2], [New York] : [2], New York, N.Y. : [1] ...
035.a 10 100.0% ocm10945712 [1], (OCoLC)ocm39109327 [1], ocm01588544 [1] ...
022.a 10 100.0% 0047-2662 [1], 0022-3387 [1], 0731-7158 [1] ...
010.a 10 100.0% 38003075 [1], 40012649 //r86 [1], 2006212058 [1] ...
040.c 10 100.0% DLC [3], MUL [3], NSD [2] ...
040.a 10 100.0% DLC [5], NSD [2], MUL [1] ...
001 10 100.0% ...
005 10 100.0% ...
008 10 100.0% ...
245.a 10 100.0% Journal of rational [1], Journal of quantitat [1], Rational living. [1] ...
222.a 10 100.0% The journal of sex r [1], Journal of quantitat [1], Journal of phenomeno [1] ...
260.b 10 100.0% Duke University Pres [1], Pergamon Press. [1], Plenum, [1] ...
210.a 9 90.0% J. psychosom. res. [1], J. phenomenol. psych [1], Psychother. priv. pr [1] ...
300.a 9 90.0% v. : [3], v. ; [2], 14 v. ; [1] ...
300.c 9 90.0% 23 cm. [4], 26 cm. [3], 27 cm. [1] ...
050.a 9 90.0% AQ5 [1], AC455.2.P73 [1], AC52 [1] ...
050.b 9 90.0% .J6 [2], P89 [1], J68 [1] ...
007 9 90.0% ...
785.w 8 80.0% (DLC) 88648219 [1], (DLC) 84643014 [1], (OCoLC)40524650 [1] ...
780.w 6 60.0% (DLC)sf 85001244 [1], (OCoLC)123208775 [1], (OCLC)1763461 [1] ...
506.a 6 60.0% Electronic access re [6] ...
037.b 6 60.0% Society for the Scie [1], Journal Press, 2 Com [1], Human Sciences Press [1] ...
310.a 6 60.0% Quarterly [2], Monthly, [1], Bimonthly, [1] ...
030.a 6 60.0% JOPSAM [1], JPRPAU [1], JPHPAE [1] ...
650.x 6 60.0% Research [5], Practice [1] ...
300.b 6 60.0% ill. ; [6] ...
530.a 5 50.0% Also available on th [5] ...
550.a 5 50.0% Issued by: Institute [1], Issued by: Society f [1], Journal of the Insti [1] ...
700.a 5 50.0% Rhine, J. B. [1], McDougall, William, [1], Stuart, Charles Edwa [1] ...
260.c 5 50.0% 1983-1987. [1], c1985- [1], c1957-c1970. [1] ...
032.a 4 40.0% 002051 [1], 281800 [1], 282400 [1] ...
032.b 4 40.0% USPS [4] ...
041.a 4 40.0% ger [1], ita [1], fre [1] ...
936.a 4 40.0% Vol. 1, no. 4 (Dec. [1], Summer 1984 [1], Jan. 1975 (surrogate [1] ...
785.x 4 40.0% 0022-2518 [1], 0748-1985 [1], 1522-9580 [1] ...
785.t 4 40.0% Journal of psychothe [1], Indiana University m [1], Journal of rational- [1] ...
700.d 4 40.0% 1895-1980. [1], 1887- [1], 1871-1938. [1] ...
780.t 3 30.0% Advances in sex rese [1], Rational living [1], Journal of rational [1] ...
321.b 3 30.0% 1965-1966 [1], 1957- [1], 1935-64 [1] ...
010.z 3 30.0% sc 80001624 [1], sn 84011556 [1], sn82-2030 [1] ...
310.b 3 30.0% -June 1970 [1], 1967- [1], 1965- [1] ...
710.b 3 30.0% Dept. of Mathematics [1], Parapsychology Labor [1], Graduate Institute f [1] ...
321.a 3 30.0% Bimonthly, [1], Three issues yearly, [1], Quarterly, [1] ...
049.a 2 20.0% PVUP[SERIAL] [1], PVUM [1] ...
776.w 2 20.0% (DLC) 68130414 [1], (OCoLC)1783365 [1] ...
580.a 2 20.0% Continued in 1983 by [1], Continued in July 19 [1] ...
090.a 2 20.0% AV6001 [1], AF204.5 [1] ...
090.b 2 20.0% .J72 [1], .J6 [1] ...
022.2 1 10.0% 1 [1] ...
210.b 1 10.0% (Online) [1] ...
022.y 1 10.0% 0022-4499 [1] ...
538.a 1 10.0% Mode of access: Worl [1] ...
515.a 1 10.0% Vol. 1 has only one [1] ...
546.a 1 10.0% English, French, Ger [1] ...
776.i 1 10.0% Also issued in print [1] ...
130.a 1 10.0% Journal of sex resea [1] ...
780.x 1 10.0% 0034-0049 [1] ...
776.x 1 10.0% 0022-4499 [1] ...
555.a 1 10.0% Vols. 1-16, 1937-52, [1] ...
245.h 1 10.0% [electronic resource [1] ...
006 1 10.0% ...
994.b 1 10.0% PVU [1] ...
994.a 1 10.0% C0 [1] ...
245.b 1 10.0% the journal of the I [1] ...
776.t 1 10.0% Journal of sex resea [1] ...
700.q 1 10.0% (Joseph Banks), [1] ...
222.b 1 10.0% (Online) [1] ...
246.a 1 10.0% Journal of rational- [1] ...
"""
from __future__ import print_function, division
import collections
import json
import pymarc
import sys
if __name__ == '__main__':
if len(sys.argv) < 2:
print('usage: marcstats.py FILE', file=sys.stderr)
sys.exit(1)
stats = collections.Counter()
examples = collections.defaultdict(collections.Counter)
with open(sys.argv[1], 'rb') as handle:
reader = pymarc.MARCReader(handle)
for i, record in enumerate(reader, start=1):
for field in record.as_dict().get('fields'):
for k, v in field.iteritems():
if k > '009':
for code, value in [(x.keys()[0], x.values()[0]) for x in v.get('subfields')]:
stats['%s.%s' % (k, code)] += 1
examples['%s.%s' % (k, code)][value] += 1
else:
stats['%s' % k] += 1
print('total\t%s\t100%%' % i)
for k, v in stats.most_common():
ex = ', '.join(['%s [%s]' % (a[:20], b) for a, b in examples[k].most_common(3)])
print('%s\t%s\t%0.1f%%\t%s ...' % (k, v, v / i * 100, ex))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment