我的这部法典已读到加拿大统计局的档案。 每一行各行各行各行,各行各行各行各行各行各行各行各行各行各行各行各行各行各行各行各行各行各行各行各处,并将外地价值储存在阵列。
我如何从CSV档案中提取只需要的领域?
例如,我有类似CSV档案。
Type,Group,No,Sequence No,Row No,Date (newline) 0,Admin,3,345678,1,26052010 (newline) 1,Staff,5,78654,3,26052010
我只需要一栏,即号码和日期。
预先感谢任何想法。
Dim myStream As StreamReader = Nothing
Hold the Parsed Data
Dim strlines() As String
Dim strline() As String
Try
myStream = File.OpenText(OpenFile.FileName)
If (myStream IsNot Nothing) Then
Hold the amount of lines already read in a counter-variable
Dim placeholder As Integer = 0
strlines = myStream.ReadToEnd().Split(Environment.NewLine)
Do While strlines.Length <> -1 Is -1 when no data exists on the next line of the CSV file
strline = strlines(placeholder).Split(",")
placeholder += 1
Loop
End If
Catch ex As Exception
LogErrorException(ex)
Finally
If (myStream IsNot Nothing) Then
myStream.Close()
End If
End Try