Is there a way to do the following?
After opening a CSV file, look in a column and count each of the unique items in it?
For example,
If I have 500GB Hard drives, 64GB Flash Drives and 6ft USB Cables, I want to be able to count up the totals for them?
The tricky part is finding unique items as they will always be different.
Do I need to "know" what my program will be actually looking for or is there a way to program it to just find unique items?
Here is the code I am working with which it currently finds TRUE items in one column.
Expand|Select|Wrap|Line Numbers
- Dim startCounting As Boolean = False
- Dim trueCount0 As Integer = 0
- Dim csvFields() As String
- For Each line As String In System.IO.File.ReadAllLines(FileName)
- csvFields = line.Split(",")
- If startCounting Then
- If csvFields(0) = String.Empty OrElse csvFields.Length < 23 Then
- Exit For
- ElseIf csvFields(23) = "True" Then
- trueCount0 += 1
- End If
- ElseIf Not startCounting AndAlso csvFields.Length >= 23 AndAlso csvFields(23) = "Device_List" Then
- startCounting = True
- End If
- Next
- Label4.Text = String.Format("{0}", trueCount0)