I need to delete some rows from csv file based on a column value. Here is my sample.csv file
Name no date sal
abc 12 06/06/10 2345
xyz 11 06/06/10 2321
qwe 10 05/07/10 4323
asd 10 05/07/10 3221
In my vb.net winforom application, I have to read this file and need to delete the rows related to 06/06/10 date column values then write the remaining rows into new.csv file. So far my program works on reading whole data present in the file. Any suggestion on this please?
Here is my code:
Dim ioFile As New System.IO.StreamReader("C:\sample.csv")
Dim ioLine As String
Dim ioLines As String
ioLine = ioFile.ReadLine
ioLines = "ID,Name,Number,Amount"
ioLines &= vbCrLf & ioLine
While Not ioLine = ""
ioLine = ioFile.ReadLine
ioLines = ioLines & vbCrLf & ioLine
End While
Dim ioWriter As New System.IO.StreamWriter("C:\new.csv")
ioWriter.WriteLine(ioLines)
ioFile.Close()
ioWriter.Close()
Hopefully this will get you started (I assumed fixed column widths as that appears to be the case from your sample file):