2012-11-26 2 views
0

vb.net .am 파일을 사용 중입니다. 그 파일에는 몇 가지 값이 들어 있습니다. 나는 vb.net을 사용하여 그 파일을 읽고 싶다.vb.net에서 csv로 텍스트 파일을 읽습니다.

file name cdr_StandAloneCluster_03_201208090909_33121.file 

data type  file 

it contain the data look like this 


cdrRecordType,"globalCallID_callManagerId","globalCallID_callId","origLegCallIdentifier","dateTimeOrigination","origNodeId","origSpan","origIpAddr","callingPartyNumber","callingPartyUnicodeLoginUserID","origCause_location","origCause_value","origPrecedenceLevel","origMediaTransportAddress_IP","origMediaTransportAddress_Port","origMediaCap_payloadCapability","origMediaCap_maxFramesPerPacket","origMediaCap_g723BitRate","origVideoCap_Codec","origVideoCap 
+1

[무엇을 시도해 봤습니까?] (http://whathaveyoutried.com) – prprcupofcoffee

답변

1

당신의 DTA를 구문 분석의 핵심은 "SPLIT"방법 여기

내가 노크 샘플 코드가를 사용하는 것입니다. 110 %는 확신 할 수 없지만 문제를 해결하는 데 더 가깝습니다.

Sub SomePrcoedure(strFilename As String) 

Dim arrRawData As Generic.List(Of String) = Nothing 
Dim arrLineItems() As String = Nothing 
Dim objStreamReader As StreamReader = Nothing 
Dim datTextLine As String = Nothing 

    '-> Validate Filename 
    If Trim(strFilename) <> "" Then 
     If FileIO.FileSystem.FileExists(strFilename) Then 
      '-> Read the WHOLE file in 
      arrRawData = New Generic.List(Of String) 
      objStreamReader = New StreamReader(Trim(strFilename)) 
      Do 
       datTextLine = objStreamReader.ReadLine() 
       If Trim(datTextLine) <> "" Then 
        arrRawData.Add(Trim(datTextLine)) 
       End If 
      Loop Until objStreamReader.EndOfStream() 
      objStreamReader.Close() 
      '-> Split EACH line data into the array arrLineItems 
      For intCounta = 0 To arrRawData.Count - 1 
       arrLineItems = Split(arrRawData(intCounta), ",") 
       'your line is now split into the array arrLineItems() 
       'process results here or store results for later or your code here.... 
      Next 
     Else 
      'file not found 
     End If 
    Else 
     'file name missing 
    End If 
    arrRawData = Nothing 
    arrLineItems = Nothing 
    objStreamReader = Nothing 
    datTextLine = Nothing 

End Sub 
관련 문제