how to change field indicators

150 views
Skip to first unread message

Heidi Frank

unread,
Aug 6, 2012, 2:51:17 PM8/6/12
to pym...@googlegroups.com

Hi all,

After having my initial newbie question resolved, I've made tremendous progress on analyzing marc records from the archivists' toolkit, but now I'm trying to write the records out to two files – separating the "good" records from the "bad".

One of the steps is to change the indicator of a 520 field from blank to 3 if it matches the abstract that I'm pulling from the equivalent EAD XML.  so I thought this would work:

for field520 in record.get_fields('520'):

  # if the content of subfield 'a' matches the EAD abstract...

      field520.indicators[0] = '3'     # line 161 in attached python script

and if I then say "print field520.indicators", I do get ['3', ' '] to print to screen.  However, when I check my marc file output by opening up the file in MarcEdit, the 520 indicators have not changed - they are still \\ instead of 3\.  It seems like I'm only modifying a local instance of that particular field, and not the actual record, so when I write that record out to the file, the record is actually not changed (...maybe?)   so I thought maybe it needs to be something like:

record['520'].indicators[0] = '3'

but then I want to only do this for this particular 520 field, not all 520 fields.  I've tried to find a basic example of changing field indicators so that they change in the record, but if it's somewhere in the pymarc documentation, I've not found it.

Can anyone shed some light on what I'm doing wrong?

thanks in advance,

heidi

ps: if it helps, I've attached my full python script and my sample file of 1423 marc records that I'm working with.

pss:  just an fyi, if you run the full script, it outputs the following 6 files:

  00-BHSmarcRecs_bad.mrc

  00-BHSmarcRecs_good.mrc

  EAD520data.txt

  lgAbstractsFile.txt

  no7XXs.txt

  noAbstractsFile.txt

00-All_MRC_sans3badRecs_EDITED.mrc
BHS.py

Heidi Frank

unread,
Aug 7, 2012, 5:52:03 PM8/7/12
to pym...@googlegroups.com
An update...  I realized that to run the script, you'd need the set of the 1423 individual EAD XML files that are used for comparison to the MARC...  so sorry about that.

also, I've since found a work-around, where I create a new 520 field with the correct indicator, delete the current 520 field, and after I've finished cycling through my 520s, I add the new 520 to the record.  I'm still very interested if there's a way to just change the indicator value of an existing field within a record...  Is it possible?

best,
heidi
Reply all
Reply to author
Forward
0 new messages