Archives

Categories

MARC Viewer Codecademy Project

I have created a Codecademy project (with a lot of help in corrections and improvements from Esther Arens!) that builds a short script to read a raw MARC record and display it in a more readable format. Try it here: http://www.codecademy.com/courses/marc-viewer/.

This is not by no means the last word in reading a MARC file and is basically a walk through of one way to do it. There are other ways and better ways that use more advanced coding, or allow more sophisticated re-use of the bits and pieces that are pulled out of the MARC record. There are also entire programmes and programming utilities designed to do this kind of thing and to manipulate MARC records, not least library management systems and things like MARCEdit. Moreover, there are limitations in formatting on the Codecademy platform that can easily be overcome by adapting the script to be run directly in an HTML file (I have done a direct simple adaptation without any further elaboration (view the HTML source to see the code and the alterations)).

I hope, if nothing else, that it gives cataloguing coders an idea of what a MARC21 record looks like under the hood and helps clarify the cataloguer’s opinions as to whether MARC must or mustn’t die. (HINT: it must).

Please see the following notes below before proceeding:

1. This project was designed for someone who has done the first few weeks of the Code Year course. By necessity it introduces some new things and an attempt has been made to explain them and encourage the cataloguer to enter the actual lines of Javascript that make up the programme. In any case, the Hints always contain the correct code needed to proceed.

2. Output will often consist of many lines, so sometimes you will have to scroll up in the console to see what has happened.

3. Some lines (including line 1!) will always produce errors, although the script will still run. This will is because MARC uses BAD and DANGEROUS characters. BAD and DANGEROUS characters are of course common in the world of cataloguing (mentioning no names…).

There are many ways this could be improved or extended if you wanted the challenge, e.g.:

  • Take the HTML version and use more HTML and CSS to make it clearer and prettier (e.g. more spacing, colour, bolding of codes). Try making it look like a specific LMS editing screen.
  • Make it capture the elements in more detail and in a more re-usable way. For instance, try making each field an object with tags, indicators, subfields, etc. as properties. This would enable more interesting things, such as…
  • A simple OPAC or even a card index display.
  • Adapt it to read MARC files with more than one record. This isn’t as hard as it sounds, in that each record ends with a specific terminator (see the guide to record structure below).

For full technical details of how a MARC21 bibliographic record is put together, see the MARC 21 Specifications for Record Structure, Character Sets, and Exchange Media Record Structure. For details of the contents and use of MARC21 fields, see LC’s MARC Standards page. For a HTML version of the completed MARC Viewer script, see my adaptation.

The Code Year programme is part of Codecademy, an online set of programming lessons. Cataloguers interested in learning to programme will find the independent CatCode Wiki useful for extra information, advice, and support. See also the #catcode hashtag on Twitter.

Do let me know if you come across any problems with it or have any comments on the project.

Thank you again to Esther for her help.

https://twitter.com/#!/EstherArensEstter

12 comments to MARC Viewer Codecademy Project

  • Cool project. I’m impressed it took you so few lines of JS to do this, I figured it out be a mess parsing the head of the MARC21 file.

    Your links to your HTML viewer all break, though. It looks like the URL is getting appended to the current location (i.e. this page): http://www.aurochs.org/aurlog/2012/03/20/marc-viewer-codecademy-project/www.aurochs.org/marc-viewer/marc-viewer.html

    It’s obvious what’s going on so I moved to http://www.aurochs.org/marc-viewer/marc-viewer.html & I fixed the link in the catcode wiki too but you probably want to update this post.

  • Thank you! I’m glad you liked it. It is limited in what it does as it’s hard to do anything with the parsed data besides a vaguely legible display. The script is also somewhat shorter than the first version I did which used the field length data from the directory rather than the field terminators…

    Thank you too for pointing out the link problems and fixing the wiki. The http bit was missing of the start if the urls. They should be OK now.

  • [...] dall’esperienza sono andato a leggere il blog dell’autore e ho scoperto che da alcuni mesi è nato CatCode, un progetto per migliorare il dialogo tra [...]

  • Thank you for very interesting project!

  • [...] has to be an RDA supporter, since that too calls for a replacement for MARC21. On Twitter, I found his professional blog with a post that explains his Code Academy project a bit more–sweet! Also, he has more links to MARC21 information as well, for a more in-depth look, it [...]

  • [...] has to be an RDA supporter, since that too calls for a replacement for MARC21. On Twitter, I found his professional blog with a post that explains his Code Academy project a bit more–sweet! Also, he has more links to MARC21 information as well, for a more in-depth look, it [...]

  • Thanks for your project.
    I did not understand what the heck the MARC is.
    Had read Wiki, but still I don’t quite understand how is this format used in reality.

    Anyway, in the nearest future if you are going to create more for codecademy – please give a learners chance to code by themself. Correct code in hints its great, but whole task in the begin, with steps – would not be redundant also.

  • mnavalny. Thank you for the comment. MARC is a very old fashioned data format used only by libraries for storing and sharing information about the books they have in their catalogues, and even then the structure is not always fully understood by those who use it every day to enter information. How it’s used by librarians is not really addressed in the viewer or the wiki and is quite hard to describe in brief, although the MARC Standards page is probably your best bet: it at least has examples. If you’re really interested I can try to point you at other resources but it is a specialised and strange area.

    Because this was aimed at library cataloguers I was mostly interested in getting them to explore what the MARC format looks like- a bit like looking at how an Access database looks like when you’ve only been entering data into forms- rather than teaching new Javascript concepts. In fact, I tried not to introduce any new Javascript unless I had to. Although I wanted to encourage some thought about the problems as it went along, I also didn’t want to put off anyone who wanted to look at MARC because they got stuck. Basically though, you’re right that this kind of thing shouldn’t generally hand-hold and give all the answers in this manner. I’m also surprised to be honest how many non-librarians with no previous experience of MARC have given this a go at all.

  • R. F.

    For Exercise 3.5, I only added var field_data = mrc_elements[i+1]; to Line 10 and I think it must be right since my answer also matches the hint. But the console keeps saying Oops, try again.. Could you please tell me what’s wrong with my code?

    I’m sorry but I asked my question here instead of the Codecademy forum since I think it’s a non-tracked course and not so many people will pay attention to my problem. I am eager to know why I got the error.

    Thanks.

  • Hello. I must confess I don’t know. I had a look at it just now and it does the same for me. I’m sure this must have worked before. The Forums for the project contain various glitches and this is the first for this one. The project checks for the entire output of the console to match a given string, so perhaps this has degraded somehow: if, for instance, Codecademy have changed the way the console prints: it wouldn’t only take a newline to format slightly differently to throw it off. Seems odd though, and I don’t want to shift blame to them prematurely. I’ll try it again on a different computer and perhaps re-input the test string or redesign the test if I get the time: I admit I haven’t looked at this too much since I first wrote it. There are a lot of Forum comments I should really look at too it seems.

    Thank you for taking the time to comment, and sorry if you’ve hit a brick wall on this.

  • R.F.

    After contacting Codecademy’s Twitter account, it now works again! Thanks for you great exercise.

  • Excellent, and thank you for letting me know! Did you manage to find out exactly what was wrong in the end?