I have a csv file which have data like this:
Date,val1,val2,val3,val4,val5,val6,.......val47,val48
18/07/2011,0,0,0,10.98,0,0,0,10.98,10.98,0,0,0,0,0....,0,0
Now i need to compare the date value of existing row with new row's date value. If equal then need to replace the existing row with new row. If not append the existing row. I tried in following way. If dates are not equal, the new row is getting added but if dates are equal could not able to replace the existing row. Any suggestions please?????
Imports System.IO
Public Class Form1
Private _fileName As String = "C:\Desktop\demo.csv"
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim reader As New StreamReader(_fileName)
Dim line As String = reader.ReadLine
Dim _newLine As String = "18/07/2011,0,0,0,0,0,0,0,10.98,10.98,0,0,0,0,10.98,0,0,0,10.98"
While line <> ""
line = reader.ReadLine
If line <> "" Then
Dim values() As String = line.Split(",")
If values(0) = "18/07/2011" Then
_fileName.Replace(line, _newLine)
End If
End If
End While
reader.Close()
End Sub
End Class