Read 3rd collumn of a CSV

chadmanvb
chadmanvb used Ask the Experts™
on
How can I read just the 3rd collumn of a csv.  Below is what I have so far?
'*******************READ CSV***********************************
        Dim workStations As New StreamReader(workstationstext)
        Dim workStationsList As String = workStations.ReadToEnd()
        Dim workStationListSplit() As String = Regex.Split(workStationsList, "\r\n")
        workStations.Close()
 
        'read each line and skip blank lines, lines that start with a ";", lines where the second char="L", and skip lines that start with an alpha char
        For Each Line As String In workStationListSplit
            If Line.Trim = Nothing Or Line.StartsWith(";") Or Line.Substring(1, 1) = "W" Then
 
                'skip blank lines, second char="W" for a windows server, and lines that start with ";" for a coment line
 
            Else
                'do stuff
                msgbox(third collumn needs to go here)
 
            End If
 
 
        Next

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
Can you post a sample File.. So i can see what logic to use
Commented:
dim cols
cols = Split(Line,";")
msgbox cols(2)

Author

Commented:
Thanks, that worked, just had to change it to:
Dim cols
cols = Split(Line, ",")
MsgBox(cols(1))

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial