文件格式处理
我有一个多行的文件,为了入库mongodb,我想把文件内容批量预处理成json格式
即:
{"BEARER_TYPE" : 2, "USER_MSISDN" : "+8608927566","UserAgent" : "iPhoneOS/4.3.3 (8J2)",.... }
{"BEARER_TYPE" : 1, "age" : "+8608927566",.... }
求教有什么办法,有的属性可能会有空的情况,不如NatLocalPort=
MongoDB
Jun 25 14:50:00 192.168.2.203 ha_web_s3a1: WAP_GATEWAY_ID=XZWAP01BAL BEARER_TYPE=2 USER_MSISDN=+8608927566 UserAgent=iPhoneOS/4.3.3 (8J2) NatLocalIP=192.168.2.203 NatLocalPort=59608 NAS_IP_Address=211.139.71.162 Client_IP_Address=10.139.171.230 URL=http://mmsc.monternet.com/ PULL_Method=2 Destination_Address=221.176.64.249 Destination_Port=80 Operation_Type=3 Incoming_Request_TIME=1372142999913 Outgoing_Request_TIME=1372142999915 Incoming_Response_TIME=1372142999916 Outgoing_Response_TIME=1372142999916 CDR_STATUS=00 Uplink_CONTENT_LENGTH=44 Downlink_CONTENT_LENGTH=0 Content_Type= Incoming_Status_Code=200 Outgoing_Status_Code=200 Statistic_Code=200 NextHop= StackInternalError=0 Host_Name=NFJD-PS-WAP-GW07-SA03 Destination_Domain=221.176.64.249 Site_Type=1 Version=2.0
Jun 25 14:50:00 192.168.2.203 ha_web_s3a1: WAP_GATEWAY_ID=XZWAP01BAL BEARER_TYPE=2 USER_MSISDN=+869001433 UserAgent=Dorado WAP-Browser/1.0.0 NatLocalIP=192.168.2.203 NatLocalPort=18762 NAS_IP_Address=211.139.71.162 Client_IP_Address=10.139.221.115 URL=http://m.baidu.com/static/tf/readmode/errorpage/errorpage.css PULL_Method=1 Destination_Address=111.13.12.15 Destination_Port=80 Operation_Type=3 Incoming_Request_TIME=1372142999881 Outgoing_Request_TIME=1372142999881 Incoming_Response_TIME=1372142999916 Outgoing_Response_TIME=1372142999916 CDR_STATUS=00 Uplink_CONTENT_LENGTH=0 Downlink_CONTENT_LENGTH=0 Content_Type=text/css Incoming_Status_Code=304 Outgoing_Status_Code=304 Statistic_Code=304 NextHop= StackInternalError=0 Host_Name=NFJD-PS-WAP-GW07-SA03 Destination_Domain=m.baidu.com Site_Type=0 Version=2.0