Marc Data Conversion

Source: Internet
Author: User

Read expected data from the data area by analyzing the directory address area

This method can read Marc in ISO format and Marc in TXT format.

 

Code
///   <Summary>

/// Get Data
///   </Summary>
///   <Param name = "record"> Marc data </Param>
///   <Param name = "chnum"> Field number </Param>
///   <Param name = "subfield"> Subfield number </Param>
///   <Returns> Value </Returns>
Public   String Getcontent ( String Record, String Chnum, String Subfield)
{
String Strdatacontent =   String . Empty;
String Datazone;
String [,] Splitedmuci;
Int Loc;
Int Startloc;
Int Len;

Loc=Record. indexof ('@');
Datazone=Record. substring (loc+ 1);
Splitedmuci=Splitmucizone (record );

For ( Int I =   0 ; I < Splitedmuci. Length /   3 ; I ++ )
{
If (Splitedmuci [I, 0 ] = Chnum)
{
Startloc =   Int . Parse (splitedmuci [I, 2 ]) - Getoffset (datazone, 0 , Int . Parse (splitedmuci [I, 2 ]);
Len =   Int . Parse (splitedmuci [I, 1 ]) - Getoffset (datazone, Int . Parse (splitedmuci [I, 2 ]), Startloc +   Int . Parse (splitedmuci [I, 1 ]);
Strdatacontent = Datazone. substring (startloc, Len -   1 );
}
}

If (Subfield =   "" )
{
Return Strdatacontent;
}
Else
{
String [] Subdata = Strdatacontent. Split ( ' $ ' );
For ( Int I =   1 ; I < Subdata. length; I ++ )
{
String Ch = Subdata [I]. substring ( 0 , 1 );
If (CH = Subfield)
{
Strdatacontent = Subdata [I]. substring ( 1 , Subdata [I]. Length - 1 );
Break ;
}
}
}
Return Strdatacontent;
}

//Replace special characters
PublicStringReplacechr (StringResult)
{
Char[] Arr;
IntNum;

Arr = Result. tochararray ();
For ( Int I =   0 ; I < Arr. length; I ++ )
{
Num = Convert. toint32 (ARR [I]);
If (Num =   32 )
{
Arr [I] =   ' # ' ;
}
Else   If (Num =   30 )
{
Arr [I] =   ' @ ' ;
}
Else   If (Num =   31 )
{
Arr [I] =   ' $ ' ;
}
Else   If (Num =   29 )
{
Arr [I] =   ' % ' ;
}
}

Result= New String(ARR );
ReturnResult;
}

// Separated by the Directory address length by 12
Public   String [] Splitmuci ( String Strmuci)
{
Int Len = Strmuci. Length /   12 ;
String [] Splitedmuci =   New   String [Len];

For ( Int I =   0 , J =   0 ; J < Len; I + =   12 , J ++ )
{
Splitedmuci [J] = Strmuci. substring (I, 12 );
}
Return Splitedmuci;
}

///   <Summary>
/// Divide the directory address area into three parts and return the split result.
///   </Summary>
///   <Param name = "strarr"> Result returned by calling splitmuci </Param>
///   <Returns> </returns>
Public   String [,] Getdata ( String [] Strarr)
{
Int Len = Strarr. length;
String [,] Datafield =   New   String [Len, 3 ];

For ( Int K =   0 ; K < Len; k ++ )
{
Int Count =   0 ;
For ( Int I =   0 , J =   3 ; Count <   3 ; I + = J, J ++ , Count ++ )
{
Datafield [K, Count] = Strarr [K]. substring (I, j );
}
}
Return Datafield;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.