0

私は本の詳細を含むアクセスファイルを持っています。詳細を取得してそれらをマークレコードに変換する必要があり、その逆も同様です。どのように行うのが最善の方法ですか?

4

3 に答える 3

1

C# での MARC 実装のコードをリリースしました。実際のコーディングを行うには、米国議会図書館の MARC ページを参照する必要があります。

http://sourceforge.net/projects/marclibrary/

ライブラリを使用している場合は、遠慮なくフィードバックをお寄せください。

マーク

于 2012-03-17T15:28:14.690 に答える
0

FWIW、これは私が10年前に書いたコードで、プロセスMARCを使用して、それらをアクセスデータベースに入れました。

これを見てから久しぶりですが、これが始まりかもしれないと思います。

'IMPORTANT NOTE:  The Marc Record's directory (this is a feature located within a Marc
'                 Record used to parse the record) uses option base 0 to list
'                 its positions for the varying fields. (See http://lcweb.loc.gov/marc)
'                 For example, in "Chumbawumba" the letter "C" would be in the zero position
'                 On the other hand, VB's Instr() function uses option base 1 to
'                 determine positions in a variable. ("C" is in position 1).
'                 Code has been adjusted to reflect this difference.
Option Explicit
Option Base 0
Const Marc21_Blank = " "            'Chr(32)  Hex 20
Const Marc21_Delimiter = ""        'Chr(31)  Hex 1F
Const Marc21_FieldTerminator = ""  'Chr(30)  Hex 1E
Const Marc21_RecordTerminator = "" 'Chr(29)  Hex 1D
Const Marc21_FillChar = "|"         'Chr(124) Hex 7C
Const Marc21_DirLength = 12         'Length of 1 direcotry Entry (option base 1)
Const Marc21_DirLengthOfFieldPos = 3 'Where the "Length of Field" number can be found in
                                     'one directory entry (by MARC definition)
Const Marc21_DirLengthOfFieldLength = 4 'The physical length of the "Length of Field" entry
                                        'Found in the directory
Const Marc21_DirStartingPos = 7 'Where the "Length of Field" number can be found in
                                     'one directory entry (by MARC definition)
Const Marc21_DirStartingPosLength = 5 'The physical length of the "Length of Field" entry
                                        'Found in the directory
Const Marc21_DirTagLength = 3 'The physical length of the "Length of Field" entry
Const Marc21_LdrLength = 24         'Length of Leader (option base 1)
Const Marc21_PositionAdjustment = 1 'Adjustment constant for Marc record (see note at top  of module)
Const Marc21_FieldTerminatorPos = 1 'Represents a place for field terminator
Const Marc21_MaxControlFieldTagValue = 9 'Tags for control fields range from "001" to "009"
Const Marc21_IndicatorLength = 1 'Length of indicator
Const Marc21_MovePastIndicators = 3 'After indicators are stored in a variable field
                                    'we should move past them to the new starting position
                                    'This new position will be a delimeter for a variable field
Const Marc21_MovePastSubfieldCode = 2 'Used to move past the delimeter and subfield code in a varible field
'Const Marc21_FieldCount = 1         'Number of fields in Directory (option base 0)
Dim mrsLeaders As Recordset 'Recordset storing Leaders from the Marcs Imported
Dim mrsTags As Recordset    'Recordset storing the Tags
Dim mrsFields As Recordset  'Recordset storing the different variable fields in the data
'***********************************************************************************************************************
' PROCEDURE:  ProcessRecord_S
'
'   PURPOSE:  From the text file passed, this sub will parse the Marc records
'             and individually send them to the subsequent modules for further parsing
'
'PARAMETERS:  sFile -- contains full path and filename of text file passed
'
'
'  Date:    Name:           Description:
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'  03/06/01 Ray       Initial Creation
'***********************************************************************************************************************
Sub ProcessRecord_S(sFile As String)
Dim iFreeFile As Integer
Dim vMarc As Variant
Dim lRTPos As Long
Dim sMarcRecord As String
Dim dbMarc As Database

 Set dbMarc = OpenDatabase("D:\Marc21\marc21.mdb")

'Made these recordsets modular because I step into two functions saving the information.
'In addition, the text file could hold thousands of records (that's a lot of loops).
 Set mrsLeaders = dbMarc.OpenRecordset("Select * From NewLeaders")
 Set mrsTags = dbMarc.OpenRecordset("Select * From NewTags")
 Set mrsFields = dbMarc.OpenRecordset("Select * From NewFields")

lRTPos = 0 'Initialize
iFreeFile = FreeFile 'Get an available Free file number
Open sFile For Input As #iFreeFile 'Open the text file.
  vMarc = Input$(LOF(iFreeFile), iFreeFile) 'Not sure what the limit is, but I have
Close #iFreeFile                            'tested data as big as 10 megs.

Do Until vMarc = "" 'Going to loop till the variant is turned into an empty string
  lRTPos = InStr(vMarc, Marc21_RecordTerminator)  'Since there can be more than one MarcRecord, we will use the position of the
                                    'Record Terminator (RT) to determine where the Marc Record ends
  sMarcRecord = Left(vMarc, lRTPos - 1) 'Record minus RT
  If Not SaveRecord_F(sMarcRecord) Then
    MsgBox "Saving Marc Record Failed"
    Exit Sub
  End If
  vMarc = Mid(vMarc, lRTPos + 1)
Loop
End Sub
'***********************************************************************************************************************
' PROCEDURE:  SaveRecord_F
'
'   PURPOSE:  Saves tags and indicators (if applicable) to the Tag table
'
'PARAMETERS:  sMarcRecord -- Marc Record passed (this string can be up to 99,999 characters long)
'
'
'  Date:    Name:           Description:
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'  03/06/01 Ray       Initial Creation
'***********************************************************************************************************************
Function SaveRecord_F(sMarcRecord As String)
Dim sLeader As String * 24
Dim sDirectory As String 'Whole Directory
Dim sVarFields As String 'All Control and Data Fields
Dim lDirectoryEnd As Long 'Position where Directory ends
Dim lDataEntries As Long  'Determines number of Field Entries
Dim lFieldLength As Long
Dim lStartingPosition As Long
Dim lLeaderID As Long
Dim lTagID As Long
Dim sField As String
Dim sDirectoryEntry() As String
Dim bControl As Boolean
Dim lCurDirEntry As Long
Const Marc21_FLP = 4  'Field Length position relative to directory

sLeader = Left(sMarcRecord, Marc21_LdrLength)  'Set Leader
lDirectoryEnd = InStr(Marc21_LdrLength + 1, sMarcRecord, Marc21_FieldTerminator) - Marc21_FieldTerminatorPos 'Set position for end of Directory (excluding FT)
sDirectory = Mid(sMarcRecord, Marc21_LdrLength + 1, lDirectoryEnd - Marc21_LdrLength)  'Set Directory minus field terminator
'Set Variable Fields by taking end of directory position, adding one
'for the FT position and then adding another "1" to mark the beginning of the
'vfields
sVarFields = Mid(sMarcRecord, lDirectoryEnd + Marc21_FieldTerminatorPos + 1)

lDataEntries = Len(sDirectory) 'Get Length of Directory

'Make sure Directory Length Matches with Marc21 Records
If lDataEntries Mod Marc21_DirLength <> 0 Then
  MsgBox "Directory Entries are messed up"
  Exit Function
End If

'Add Leader to Leader Table
mrsLeaders.AddNew
  lLeaderID = mrsLeaders!LeaderID 'Need this newly assigned ID to process info below
  mrsLeaders!leader = sLeader
mrsLeaders.Update

'Get Number of Directory Entries for this Marc Record
lDataEntries = lDataEntries / Marc21_DirLength

'Store Tag information and, while still looping, store Variable Field Info pertaining
'to TagID pertaining to Leader
For lCurDirEntry = 0 To lDataEntries - 1

    'Starting Position of Field Entry
    lStartingPosition = Val(Mid(sDirectory, lCurDirEntry * Marc21_DirLength + Marc21_DirStartingPos + Marc21_PositionAdjustment, Marc21_DirStartingPosLength))
    'Field length in directory relative to current record
    lFieldLength = Val(Mid(sDirectory, (lCurDirEntry * Marc21_DirLength) + Marc21_DirLengthOfFieldPos + Marc21_FieldTerminatorPos, Marc21_DirLengthOfFieldLength))


    mrsTags.AddNew
      mrsTags!LeaderID = lLeaderID
      'According to MARC, the tag within a directory starts at position zero, so we adjust it by one for the MID function
      mrsTags!Tag = Mid(sDirectory, lCurDirEntry * Marc21_DirLength + Marc21_PositionAdjustment, Marc21_DirTagLength)

      'Set indicators for Data Fields (non-control fields)
      If Val(mrsTags!Tag) > Marc21_MaxControlFieldTagValue Then
        mrsTags!Indicator1 = Mid(sVarFields, lStartingPosition + 1, Marc21_IndicatorLength)
        mrsTags!Indicator2 = Mid(sVarFields, lStartingPosition + 2, Marc21_IndicatorLength)
        lStartingPosition = lStartingPosition + Marc21_MovePastIndicators
        lFieldLength = lFieldLength - Marc21_MovePastIndicators 'Adjust field length accordingly
        bControl = False
      Else
        lStartingPosition = lStartingPosition + Marc21_PositionAdjustment  'Adjusted b/c Marc21's defines positions of fields based on position zero.  VB uses base 1.  Imagine that.
        bControl = True
      End If
      lTagID = mrsTags!TagID
      'mrsTags!FieldDesc = Mid(sVarFields, lStartingPosition + 1, lFieldLength - 1) 'Directory Entry - Field Termintor (FT)
    mrsTags.Update
    'Only Get field pertaining to Direcotry Entry Just Saved
    sField = Mid(sVarFields, lStartingPosition, lFieldLength)
    SaveFields_F sField, lTagID, bControl 'Adding and Subtracting two is accounting for indicators
Next lCurDirEntry

SaveRecord_F = True
End Function
'***********************************************************************************************************************
' PROCEDURE:  SaveFields_F
'
'   PURPOSE:  Saves the variable data and control fields to its respective table
'
'PARAMETERS:  sField -- The data which must be filtered
'             lTagID -- The unique identifier related to the records about to be stored
'           bControl -- Optional.  Let's sub know if data is a control field or not
'
'
'  Date:    Name:           Description:
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'  03/06/01 Ray       Initial Creation
'***********************************************************************************************************************
Function SaveFields_F(sField As String, lTagID As Long, Optional bControl As Boolean)
Dim lDelimeterPos As Long

If Not bControl Then 'Not a control Field
  If Left(sField, 1) = Marc21_Delimiter Then
    sField = Mid(sField, 2) 'Move past delimeter
  Else
    'All non-control fields should start with delimeters
    MsgBox "This entry didn't start out with a delimeter", vbOKOnly, "Uh Oh"
    Exit Function
  End If
  lDelimeterPos = InStr(1, sField, Marc21_Delimiter)
  Do Until lDelimeterPos = 0
    'Store new subfield code and field description
    mrsFields.AddNew
      mrsFields!TagID = lTagID
      mrsFields!SubFieldCode = Left(sField, 1)
      mrsFields!FieldDesc = Mid(sField, Marc21_MovePastSubfieldCode, lDelimeterPos - Marc21_MovePastSubfieldCode) 'Start at position two b/c of subfield code.  Subtract by 2 b/c of where started
    mrsFields.Update
    sField = Mid(sField, lDelimeterPos + 1)
    'Get new delimeter position
    lDelimeterPos = InStr(1, sField, Marc21_Delimiter)
  Loop
  If sField <> "" Then
    mrsFields.AddNew
      mrsFields!TagID = lTagID
      mrsFields!SubFieldCode = Left(sField, 1)
      mrsFields!FieldDesc = Mid(sField, Marc21_MovePastSubfieldCode)
    mrsFields.Update
  End If

Else
  If sField <> "" Then
    If Right(sField, 1) = Marc21_FieldTerminator Then
      sField = Mid(sField, 1, Len(sField) - Marc21_FieldTerminatorPos)
    End If
    mrsFields.AddNew
      mrsFields!TagID = lTagID
      mrsFields!FieldDesc = sField
    mrsFields.Update
  End If
End If
End Function

私が作成した(そして使用した)アクセスデータベースはここにあります。

于 2011-04-19T20:17:51.850 に答える
0

1回のジャンプでそこにたどり着くものを見つけるとは思えません。あなたの最善の策は、お気に入りのデータ アクセス手法を使用して Access からレコードを読み取り、それを MARC を話すものに送り込むことです。私はそれを使用していませんが、MARCNet プロジェクトは有望に見えます。MARC 形式を手動で実装するのはそれほど難しくありません(基本的にはすべてテキストのフラット ファイルにすぎません)。

于 2010-07-26T21:52:12.940 に答える