Hey
I am new to vb and programming in general and I have this problem I just cant fix, so if anyone could help that would be great!!
I am trying to pull a column of numbers out of a csv file, sort them, eliminate duplicates and put the rest in a new textfile. My problem is that the output file from the arraylist is wrong.
In stead of a list of numbers like this:
1
2
3
I get:
1
1
2
1
2
3
This is what I what I got:
I put the extra output to textfile (ID3temp) in because I thought it might help me figure out what the problem was but the file contains the unsorted list just as it should.
Any input to fix this is greatly appreciated
I am new to vb and programming in general and I have this problem I just cant fix, so if anyone could help that would be great!!
I am trying to pull a column of numbers out of a csv file, sort them, eliminate duplicates and put the rest in a new textfile. My problem is that the output file from the arraylist is wrong.
In stead of a list of numbers like this:
1
2
3
I get:
1
1
2
1
2
3
This is what I what I got:
VB.NET:
Dim sr1 As New IO.StreamReader(Path1.Text)
Dim Linecont1() As String
Dim header1 As String
Dim Linelist1 As String
Dim delim As String = ";"
Dim i As Integer = -1
Dim ID3table As New ArrayList
Dim result As New System.Text.StringBuilder
Dim ID3 As String
header1 = sr1.ReadLine
Dim sw1 As New IO.StreamWriter(My.Computer.FileSystem.GetParentPath(Path1.Text) & "/ID3temp.text")
Dim sw2 As New IO.StreamWriter(My.Computer.FileSystem.GetParentPath(Path1.Text) & "/ID3.text")
Dim count As Integer = ID3table.Count
Do While Not sr1.EndOfStream
Linelist1 = sr1.ReadLine
Linecont1 = Linelist1.Split(delim)
ID3 = Linecont1(10)
sw1.WriteLine(ID3)
ID3table.Add(ID3)
Loop
sw1.Close()
ID3table.Sort()
For j = count - 1 To 1 Step -1
If (ID3table(j).ToString() = ID3table(j - 1).ToString()) Then
ID3table.RemoveAt(j)
End If
For Each ID3 In ID3table
result.AppendLine(ID3)
sw2.Write(result.ToString())
Next ID3
I put the extra output to textfile (ID3temp) in because I thought it might help me figure out what the problem was but the file contains the unsorted list just as it should.
Any input to fix this is greatly appreciated