From a Microsoft article, I got some basic information on using sql
techniques to read a csv file - I am using the code below, which does work.
Unfortuneately, when I try to make the sql statement fancier (select * from
webdata.csv where Name='bj') I get an error. similiar errors occur if I try
to reference the column by name with the datareader (dr.item("Name") as
opposed to dr.item(0)).
Though I am experimenting on some small csv files, my eventual goal is to
use something like this to analyze large (400MB) log files.
Any thoughts or additional articles would be a great help.
thanks
-------------------------------------
Public Sub ReadCSVnet()
Dim Conn As OleDbConnection
Dim dr As OleDbDataReader
Dim da As OleDbDataAdapter
Dim myCommand As OleDbCommand
Dim strPathtoTextFile As String
Dim sql As String
strPathtoTextFile = "C:\Data\"
sql = "Select * from webdata.csv"
Conn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; " &
"Data Source=" & strPathtoTextFile & ";" & "Extended
Properties=""text;HDR=YES;FMT=Delimited""")
myCommand = New OleDbCommand(sql, Conn)
Conn.Open()
dr = myCommand.ExecuteReader()
While dr.Read
msg.Text += "Name: " & dr.Item(0) & " - "
msg.Text += "occupation: " & dr.Item(1) & "<br>"
End While
dr.Close()
Conn.Close()
End Sub
-------------------------------------
csv file looks like
"name", "occupation"
"bj", "director"
"neil", "web"
bj daniels
da******@gunnery.org