jaya14
Dec 19th, 2005, 09:50 AM
I have a CSV file I want to manipulate. I am dropping the csv into a list box, then going through line by line. I want to check a column for duplicates, and then:
---ex of the columns in csv file---
Column1-----Column2--------Column3
------------------------------------
004.tif----------9------------Keep
005.tif---------10
006.tif---------13
004.tif---------15------------Bad
007.tif---------17
004.tif---------25------------Bad
1.) if there is a duplicate (004.tif), go to the next column(2) and store the value in a field. Then if I come across another value which is a duplicate(4th line), check the other column and compare the 2 values, keeping the lowest, and flagging the higher one with a value in another column(3) so the result would look something like what you see above. I already have a function to put the csv into a list box:
Private Function CSV2ListBox()
'This function gets all data from the specified csv file,
'and places it in row by row in a listbox
Dim filetoread As String
Dim filestream As StreamReader
Dim readcontents As String
Dim s As String
Dim a() As String
Dim j As Integer
filetoread = System.IO.Path.GetFullPath("C:\len\test.csv")
filestream = File.OpenText(filetoread)
readcontents = filestream.ReadToEnd()
s = readcontents
lstResult.Items.Clear()
a = s.Split(vbLf)
For j = 0 To a.GetUpperBound(0) - 1
lstResult.Items.Add(a(j))
Next
End Function
Any help is greatly appreciated
---ex of the columns in csv file---
Column1-----Column2--------Column3
------------------------------------
004.tif----------9------------Keep
005.tif---------10
006.tif---------13
004.tif---------15------------Bad
007.tif---------17
004.tif---------25------------Bad
1.) if there is a duplicate (004.tif), go to the next column(2) and store the value in a field. Then if I come across another value which is a duplicate(4th line), check the other column and compare the 2 values, keeping the lowest, and flagging the higher one with a value in another column(3) so the result would look something like what you see above. I already have a function to put the csv into a list box:
Private Function CSV2ListBox()
'This function gets all data from the specified csv file,
'and places it in row by row in a listbox
Dim filetoread As String
Dim filestream As StreamReader
Dim readcontents As String
Dim s As String
Dim a() As String
Dim j As Integer
filetoread = System.IO.Path.GetFullPath("C:\len\test.csv")
filestream = File.OpenText(filetoread)
readcontents = filestream.ReadToEnd()
s = readcontents
lstResult.Items.Clear()
a = s.Split(vbLf)
For j = 0 To a.GetUpperBound(0) - 1
lstResult.Items.Add(a(j))
Next
End Function
Any help is greatly appreciated