CSharp MARC

  • Increase font size
  • Default font size
  • Decrease font size
CSharp MARC

New FileMARCXMLWriter and Full MARCXML Support!

E-mail Print PDF

The latest version of CSharp_MARC has a new class: FileMARCXMLWriter. While my previous releases were able to import and manipulate records that were stored as XML, they did not have the capability of writing them back out. With this release, CSharp MARC finally has full MARCXML support. Just like FileMARCWriter, it supports both List<Record> as well as individual records. In addition, the Record object has a new function ToXML(), which returns an XDocument. Fields and Subfields also have a ToXML() function, each that return an XElement that matches the given field or subfield if you wish to use them. Making use of the new ToXML functions requires adding "using System.Xml.Linq" to your project's using statements.

The official release will happen after I do some more testing, but for now you can get started using MARCXML by downloading the latest code from the Sourceforge SVN tree.

Here's a quick example of the new FileMARCXMLWriter's use:

List<Record> records = new List<Record>();
//Fill your list of records just like you always have

FileMARCXMLWriter writer = new FileMARCXMLWriter(filename);
writer.Write(records);
writer.Dispose();
Last Updated on Monday, 03 February 2014 15:34
 

New FileMARCWriter

E-mail Print PDF

The new RDA format for MARC21 uses the copyright symbol in place of the letter c in the 260 tag. This leads to an interesting problem with MARC21 files when it comes to including special characters because the actual encoding is generally MARC8 which is not supported by .Net rather than UTF-8/Unicode which .Net does support. Generally special characters aren't a huge problem, unless you are working with a lot of large collections full of foreign books, which is something I have never had to deal with before. The copyright symbol is, however, a problem that I needed to solve in order to make sure my class structures do support RDA. Since most of the people I build records for expect them to be encoded in MARC8 rather than UTF-8, I had to make sure that these files were being written and read correctly.  If you want to read more about the problem in particular, check out Mark Sullivan's blog. Mark is the developer of another set of class structures, and has taken a slightly different approach than I have. His blog post does a wonderful job of explaining the problem in detail, and talking about how to fix it. While my solution isn't as fully featured as the MARC8 support in Mark's SobekCM MARC Library, it does support writing files back out in MARC8 rather than fully converting them to UTF-8.

The latest version of CSharp_MARC, released today, has a new class: FileMARCWriter. Not only does this make writing records out to files easier, but it also has the benefit of supporting a select number of special characters. Currently the only characters supported are the visible characters in the A-C rows of the ANSEL MARC8 encoding. More will be coming soon, as it will take some time to add the full MARC8 character set.

Here's a quick example of the new FileMARCWriter's use:

List<Record> records = new List<Record>();
//Fill your list of records just like you always have

FileMARCWriter writer = new FileMARCWriter(filename);
foreach (Record marc in records)
{
          //modify each record as you normally would
          writer.Write(record);
}
writer.WriteEnd(); //Write the end of file (Hex 1A) character
writer.Dispose();
Last Updated on Wednesday, 10 April 2013 17:01
 

Now supporting large files

E-mail Print PDF

Thanks to some feedback from users, I've implemented an update to CSharp MARC to support large files.  In order to support the current API and not break how the FileMARC class was intended to be used (which is loading an entire file into memory and then doing batch processing on it), I added a FileMARCReader class.

The FileMARCReader class simply takes a filename and allows it to be used as an IEnumerator.  It reads the file in small memory-efficient chunks and spits out records one at a time in order.  This will hopefully help those who need to work with large files.

Here's a quick example of its use:

string filename = "manyrecords.mrc";
FileMARCReader reader = new FileMARCReader(filename);
foreach (Record marc in reader)
{
//Do whatever you'd normally do on a Record object
}
reader.Dispose();
Last Updated on Wednesday, 13 June 2012 13:48
 

Welcome to the homepage of CSharp MARC!

E-mail Print PDF

This is the new home of CSharp MARC, a C# Class Library for accessing and manipulating MARC Records.

Until this site is fully up and running, please visit the project page on Sourceforge: http://sourceforge.net/projects/csharpmarc/

Please check back soon when the site is finished!

Last Updated on Saturday, 19 February 2011 13:39