Parsing records in mathematica
- To: mathgroup at smc.vnet.net
- Subject: [mg38060] Parsing records in mathematica
- From: burd at gmx.net (Oleg)
- Date: Thu, 28 Nov 2002 14:08:05 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
Hi, does smbd knows any possibility to parse in Mathematica complex structures. Example: File datafile consist of 1000 records. Each record is defined by C structure pubcstnTag: typedef struct pubcstnTag { char dataLen[DATA_LEN_LEN]; instGrpIdCodT instGrpIdCod; instDataT instData; } pubcstnT, *pPubcstnT; This structures consist of the following one: #ifndef _BST_ORD_GRP_T_ #define _BST_ORD_GRP_T_ typedef struct bstOrdGrpTag { char bstBidPrc[BST_BID_PRC_LEN+1]; char bstAskPrc[BST_ASK_PRC_LEN+1]; char bstBidQty[BST_BID_QTY_LEN+1]; char bstAskQty[BST_ASK_QTY_LEN+1]; char numOrdrBid[NUM_ORDR_BID_LEN+1]; char numOrdrAsk[NUM_ORDR_ASK_LEN+1]; } bstOrdGrpT, *pBstOrdGrpT; #endif /* _BST_ORD_GRP_T_ */ /*----------------------------------------------------------------------------*/ #ifndef _MTCH_RNG_T_ #define _MTCH_RNG_T_ typedef struct mtchRngTag { char mtchRngBid[MTCH_RNG_BID_LEN+1]; char mtchRngAsk[MTCH_RNG_ASK_LEN+1]; } mtchRngT, *pMtchRngT; #endif /* _MTCH_RNG_T_ */ /*----------------------------------------------------------------------------*/ #ifndef _INST_DATA_T_ #define _INST_DATA_T_ typedef struct instDataTag { char auctPrc[AUCT_PRC_LEN+1]; char auctQty[AUCT_QTY_LEN+1]; char netChg[NET_CHG_LEN+1]; char lstTrdPrc[LST_TRD_PRC_LEN+1]; char lstTrdQty[LST_TRD_QTY_LEN+1]; char trdTim[TRD_TIM_LEN]; char crossTrdPrc[CROSS_TRD_PRC_LEN+1]; char crossTrdQty[CROSS_TRD_QTY_LEN+1]; char crossTrdTim[CROSS_TRD_TIM_LEN]; char clsPrc[CLS_PRC_LEN+1]; char valPrc[VAL_PRC_LEN+1]; char opnPrc[OPN_PRC_LEN+1]; char dlyLowPrc[DLY_LOW_PRC_LEN+1]; char dlyHghPrc[DLY_HGH_PRC_LEN+1]; char instOneDayQtyBest[INST_ONE_DAY_QTY_BEST_LEN+1]; char totNoTrdBest[TOT_NO_TRD_BEST_LEN+1]; char trdPrcBest[TRD_PRC_BEST_LEN+1]; char trdQtyBest[TRD_QTY_BEST_LEN+1]; char trdTimBest[TRD_TIM_BEST_LEN]; char instOneDayQty[INST_ONE_DAY_QTY_LEN+1]; char lstAuctQty[LST_AUCT_QTY_LEN+1]; char auctTim[AUCT_TIM_LEN]; char lstAuctPrc[LST_AUCT_PRC_LEN+1]; char quotTypInd; char srpQty[SRP_QTY_LEN+1]; char noTotTrdQty[NO_TOT_TRD_QTY_LEN+1]; char fmInd; char srpBidAskInd; char moiInd; char prcsStsValCod[PRCS_STS_VAL_COD_LEN]; char cmexInd; char volInd; char excpStateInd; mtchRngT mtchRng; char bstOrdPrcInd; bstOrdGrpT bstOrdGrp[BST_ORD_GRP_MAX]; } instDataT, *pInstDataT; #endif /* _INST_DATA_T_ */ /*----------------------------------------------------------------------------*/ #ifndef _INST_GRP_ID_COD_T_ #define _INST_GRP_ID_COD_T_ typedef struct instGrpIdCodTag { char isinCod[ISIN_COD_LEN]; } instGrpIdCodT, *pInstGrpIdCodT; #endif /* _INST_GRP_ID_COD_T_ */ /*----------------------------------------------------------------------------*/ typedef struct pubcstnTag { char dataLen[DATA_LEN_LEN]; instGrpIdCodT instGrpIdCod; instDataT instData; } pubcstnT, *pPubcstnT; Example of record: "1091DE0005190037-9999999999999+\ 000000000000000+0000000017000 \ \ \ +000000000000000 \ NNTRADE N \ C+0000002153000+0000002169000+000000003000000+000000000150000+0001+0001+\ 0000002152000+0000002170000+000000003100000+000000000500000+0001+0001+\ 0000002135000+0000002174000+000000001464000+000000001300000+0001+0002+\ 0000002126000+0000002175000+000000001000000+000000001740000+0001+0001+\ 0000002125000+0000002179000+000000000100000+000000000500000+0001+0001+\ 0000002100000+0000002180000+000000000500000+000000002000000+0001+0001+\ 0000002071000+0000002186000+000000001000000+000000000300000+0001+0001+\ 0000002070000+0000002189000+000000000357000+000000001000000+0002+0001+\ 0000002045000+0000002190000+000000000240000+000000000500000+0001+0001+\ 0000002021000+0000002193000+000000001000000+000000000250000+0001+0001]]" I read the file into the list. But how to parse records in the way to be able to access single elements of the structures?