T
Tom Nowak
I am trying to create a graph based on data in a CSV file. The routine below
gets one value, but i want to keep reading the file, and string all the data
(comma delimited) together into the array, then do the graph processing. The
code below only get the last value in the file. How do I get all the data in
the file? The commented out code at the top works, but I do not want to
hardcode values. Please help:
Function GetBarValues()
'barValue = New Integer() {18, 45, 163, 226, 333, _
' 3, 183, 305, 329, 73, _
' 271, 132, 348, 272, 64}
'Return barValue
Try
Dim textin As New StreamReader(New FileStream(path,
FileMode.OpenOrCreate, FileAccess.Read))
Response.Write("System Stats<br>")
Response.Write("<br>")
Response.Write("<table>")
Do While textin.Peek <> -1
Dim i As Integer
Dim row As String = textin.ReadLine
Dim columns() As String = row.Split(CChar(","))
For i = 0 To columns.Length - 1
barValue = New Integer() {CInt(columns(i))}
Next
Loop
textin.Close()
Catch ex As Exception
lblError.Text = "The file could not be read: " & _
ex.Message
End Try
Return barValue
End Function
gets one value, but i want to keep reading the file, and string all the data
(comma delimited) together into the array, then do the graph processing. The
code below only get the last value in the file. How do I get all the data in
the file? The commented out code at the top works, but I do not want to
hardcode values. Please help:
Function GetBarValues()
'barValue = New Integer() {18, 45, 163, 226, 333, _
' 3, 183, 305, 329, 73, _
' 271, 132, 348, 272, 64}
'Return barValue
Try
Dim textin As New StreamReader(New FileStream(path,
FileMode.OpenOrCreate, FileAccess.Read))
Response.Write("System Stats<br>")
Response.Write("<br>")
Response.Write("<table>")
Do While textin.Peek <> -1
Dim i As Integer
Dim row As String = textin.ReadLine
Dim columns() As String = row.Split(CChar(","))
For i = 0 To columns.Length - 1
barValue = New Integer() {CInt(columns(i))}
Next
Loop
textin.Close()
Catch ex As Exception
lblError.Text = "The file could not be read: " & _
ex.Message
End Try
Return barValue
End Function