Read Embedded CSV

hawk

Member
Joined
Sep 6, 2008
Messages
8
Programming Experience
Beginner
Hi All,

Hopefully something relatively easy you guys can direct me on.

Currently I have an external csv that I read and then search for results. I want to now embed this as a resource but without much luck.

Any advice welcome - current code below.

VB.NET:
Dim path As String = "C:\music.csv"
Dim sr As StreamReader = File.OpenText(path)

Do While sr.Peek()

            Dim test1 As Double
            Dim test2 As Double

Dim line As String = sr.ReadLine()

Dim fields() As String = Split(line, ",")

perform some actions

sr.Close()
 
Open project properties, Resources tab. Add the csv there, either using the provided interface, dragging file in, or copy from Windows Explorer and paste it there.
Read the resource in code using the My.Resources object, eg My.Resources.csvname returns the text content of the file.
My.Resources Object (Visual Basic)
To read the contents line by line, either split the string or use a StringReader.
 
Back
Top