Build New Field Enhancements

By reeset / On / In MarcEdit

Couple of interesting questions this week got me thinking about a couple of enhancements to MarcEdit.  I’m not sure these are things that other folks will make use of often, but I can see these being really useful answering questions that come up on the listserv.

The particular question that got me thinking about this today was the following scenario:

The user has two fields – an 099 that includes data that needs to be retained, and then an 830$v that needs to be placed into the 099.  The 830$v has trailing punctuation that will need to be removed. 

Example data:
=099  \\$aELECTRONIC DATA
=830  \\$aSeries Title $v 12-031.

The final data output should be:
=099  \\$aELECTRONIC RESOURCE 12-013
=830  \\$aSeries Title $v 12-031.

With the current tools, you can do this but it would require multiple steps.  Using the current build new field tool, you could create the pattern for the data:
=099  \\$a{099$a} {830$v}

This would lead to an output of:
=099  \\$aELECTRONIC RESOURCE 12-031.

To remove the period – you could use a replace function and fix the $a at the same time.  You could have also made the ELECTRONIC RESOURCE string a constant in the build new field – but the problem is that you’d have to know that this was the only data that ever showed up in the 099$a (and it probably won’t be).

So thinking about this problem, I’ve been thinking about how I might be able to add a few processing “macros” into the pattern language – and that’s what I’ve done.  At this point, I’ve added the following commands:

  • replace(find,replace)
  • trim(chars)
  • trimend(chars)
  • trimstart(chars)
  • substring(start,length)

The way that these have been implemented – these commands are stackable – they are also very ridged in structure.  These commands are case sensitive (command labels are all lower case), and in the places where you have multiple parameters – there are no spaces between the commas. 

So how does this work – here’s some examples (not full patterns):
{099$a.trim(“.”)}
{050$b.replace(“1950”,”1980”).trim(“.”)}
{LDR.substring(6,1)}

As you can see in the patterns, the commands are initialized by adding “.command” to the end of the field pattern.  So how we would apply this to the user story above.  It’s easy:
=099  \\$a{099$a.replace(“DATA”,”RESOURCE”)} {830$v.trimend(“.”)}

And that would be it.  With this single pattern, we can run the replacement on the data in the 099$a and trim the data in the 830$v. 

Now, I realize that this syntax might not be the easiest for everyone right out of the gate, but as I said, I’m hoping this will be useful for folks interested in learning the new options, but am really excited to have this in my toolkit for answering questions posed on the listserv.

This has been implemented in all versions of MarcEdit, and will be part of this weekend’s update.

–tr

One thought on “Build New Field Enhancements