By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,199 Members | 1,458 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,199 IT Pros & Developers. It's quick & easy.

analyzing a csv using sql commands

P: n/a
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.

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

myCommand = New OleDbCommand(sql, Conn)
dr = myCommand.ExecuteReader()
While dr.Read
msg.Text += "Name: " & dr.Item(0) & " - "
msg.Text += "occupation: " & dr.Item(1) & "<br>"
End While

End Sub
csv file looks like
"name", "occupation"
"bj", "director"
"neil", "web"
bj daniels
Nov 18 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.