Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > analyzing a csv using sql commands

Reply
Thread Tools

analyzing a csv using sql commands

 
 
bj daniels
Guest
Posts: n/a
 
      05-12-2004
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



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
read CSV file using csv library Li Chen Ruby 18 03-23-2010 12:44 AM
read and write csv file using csv module jliu66 Python 0 10-19-2007 03:12 PM
Need a good resource for analyzing show commands ccunning001 Cisco 0 10-25-2006 03:28 PM
Need Help Differentiating Bad Commands From Incomplete Commands Tim Stanka Python 1 08-02-2004 02:08 AM
Re: man pages for C commands (GCC commands) Ben Pfaff C Programming 4 06-28-2003 06:21 PM



Advertisments