I have a .CSV file with about 30 columns of data and about 8,000 rows. I'm able to access the data if I access columnes 1-8, if I switch it to try to read 9 or further, it says that there is a null reference in the array. I've searched through the data and it is pretty straight forward data, numbers, decimals, times, etc.... Is this a limitation on the streamreader? My code that works on columns 1-8.
Public Sub GetTakeoffLatitude(ByVal FilePath As String)
Dim folderPath As String = Server.MapPath("csvFiles") & "\" & System.IO.Path.GetFileName(FilePath)
Dim sr As System.IO.StreamReader = System.IO.File.OpenText(folderPath)
Dim record As String = sr.ReadLine()
Do Until record Is Nothing
Dim fields() As String = record.Split(",")
Dim s As String = fields(4)
If s.Contains("_") Or s.Contains("Latitude") Or s.Contains("degrees") Or s.ToString.Trim.Length < 1 Then
'Keep going for first numerical record
_TakeOffLat = s.Trim.ToString()
record = sr.ReadLine()
But if I change this line: Dim s As String = fields(4)
To say 8 or 9:
ption: Index was outside the bounds of the array.
Thanks in advance.