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 OleDbDataAdapte r
Dim myCommand As OleDbCommand
Dim strPathtoTextFi le As String
Dim sql As String
strPathtoTextFi le = "C:\Data\"
sql = "Select * from webdata.csv"
Conn = New OleDbConnection ("Provider=Micr osoft.Jet.OLEDB .4.0;" &
"Data Source=" & strPathtoTextFi le & ";" & "Extended
Properties=""te xt;HDR=YES;FMT= Delimited""")
myCommand = New OleDbCommand(sq l, Conn)
Conn.Open()
dr = myCommand.Execu teReader()
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******@gunner y.org