• Stars
    star
    112
  • Rank 312,240 (Top 7 %)
  • Language
    Go
  • License
    MIT License
  • Created over 7 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

MARC command line parser

What is this?

MARC command line (marcli) is a tool to parse MARC files from the command line.

The goal of marcli is to allow a user to parse large MARC files in either MARC binary or MARC XML form and provide basic functionality to find specific records within a file.

Installation

On the Mac or Linux the easiest way to install marcli is via Homebrew:

brew install marcli
marcli -file yourfile.mrc

Or by downloading the binary for your OS from the releases tab and marking the downloaded file as an executable:

curl -LO https://github.com/hectorcorrea/marcli/releases/latest/download/marcli
chmod u+x marcli
./marcli -file yourfile.mrc

Notice that if you install marcli via Homebrew the executable will be on your path and you can run it just by typing marcli from any folder, whereas if you install it via cURL you need to indicate the path ./marcli.

Sample of usage

Output MARC data to the console in a line delimited format (marcli automatically detects whether the file provided is in MARC XML or MARC binary):

./marcli -file data/test_1a.mrc
./marcli -file data/test_10.xml

Extract MARC records on file that contain the string "wildlife"

./marcli -file data/test_10.mrc -match wildlife

Extracts MARC records on file that contain the string "wildlife" but outputs only fields "LDR,001,040,245a,650" for each record, LDR means the leader of the MARC record. In the -fields parameter a letter (or letters) after the field tag indicates to output only those subfields. For example "907xz" means output subfield "x" and "z" in field "907".

./marcli -file data/test_10.mrc -match wildlife -fields LDR,010,040,245a,650

The -matchFields parameter can be used to limit the fields where the match will be made:

./marcli -file=data/test_10.mrc -match=web -matchFields=530

You can also use the exclude option to indicate fields to exclude from the output (notice that only full fields are supported here, e.g. 970 is accepted but not 970a)

You can also filter based on the presence of certain fields in the MARC record (regardless of their value), for example the following will only output records that have a MARC 110 field:

./marcli -file data/test_10.mrc -hasFields 110

By default the output is in Mnemonic MARC (.mrk), which is a human readable format. You can use the format parameter to output MARC XML, MARC JSON, or MARC binary instead. Notice that not all the features are available in all the formats.

You can also pass start and count parameters to output only a range of MARC records.

Sample data

Files under ./data/ are small MARC files that I use for testing.

  • test_10.mrc has 10 MARC records (MARC binary)
  • test_1a.mrc is the first record of test_10.mrc (MARC binary)
  • test_1b.mrc is the second record of test_10.mrc (MARC binary)
  • test_10.xml same as test_10.mrc but in MARC XML.

Getting started with the code

Download the code and play with it:

cd ~/src
git clone https://github.com/hectorcorrea/marcli.git
cd marcli/cmd/marcli
go build
./marcli -file ~/src/marcli/data/test_1a.mrc

Code Structure

  • cmd/marcli contains the code for the command line interface.
  • pkg/marc contains the code to parse MARC files.

Bugs, feedback, ideas?

If you find an issue parsing MARC files with marcli feel free to submit an issue with details of the error, and if possible a sample file or contact me by email at [email protected]

More information

More Repositories

1

solr-for-newbies

Materials for the Solr for newbies workshop
HTML
69
star
2

binary-tree

Binary tree and Binary Tree Drawer in Ruby
Ruby
19
star
3

hectorcorrea.com

Source code for hectorcorrea.com
Go
15
star
4

intro-to-nodejs

Code samples for my Intro to Node.js session
JavaScript
15
star
5

jaguarDb

The simplest database for Node.js that could possible work.
JavaScript
11
star
6

ldpserver

A mini LDP Server written in Go.
Go
11
star
7

solrdora

A quick and easy way to explore the data in your Solr core
Go
6
star
8

solrcli

Solr Command Line Interface (solrcli) is a text based user interface to submit queries to Solr directly from a Linux terminal.
Go
4
star
9

intro-to-coffeescript

A decaf introduction to CoffeeScript
CoffeeScript
3
star
10

binary-tree-coffee

A binary tree in CoffeeScript
JavaScript
3
star
11

solr

A Solr client written in Go.
Go
2
star
12

blazegraph_demo

A quick demo on how to get started with Blazegraph
2
star
13

mongoConnect

A wrapper for MongoDB's MongoClient that handles keeping the connection open and dealing with reconnections.
JavaScript
2
star
14

unpaydisco

A proof of concept to create a simple discovery layer on top of the Unpaywall.org data.
Go
2
star
15

fedora4

Playing with Fedora 4
Ruby
2
star
16

riceonrails

A simple demo on how to integrate Jasmine on a Ruby on Rails app
JavaScript
1
star
17

intro-to-nosql-with-mongodb

Slides and code examples for my Introduction to NoSQL with MongoDB presentation
JavaScript
1
star
18

tiny-container

A tiny Linux container
Go
1
star
19

rdf

Utilities to work with RDF in Go
Go
1
star
20

fuseki_demo

A quick demo on how to get started with Apache Jena Fuseki
1
star