473,503 Members | 9,735 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

analyzing a csv using sql commands

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
Nov 18 '05 #1
0 919

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
11028
by: Frog | last post by:
Hi, i'm not a programmer so I have a very stupid question. I'm trying to make a practical script. I need to run an executable program in it but i can't get it to work. Maybe someone here can...
10
3379
by: Virginia | last post by:
We have a product that runs on Oracle. The version of Oracle I'm working with is 8.1.7. I should also note that I'm relatively new to Oracle. I'm troubleshooting one particular database that is...
1
21366
by: Junior | last post by:
I keep receiving this "The type or namespace name 'CASsEventHandler' could not be found (are you missing a using directive or an assembly reference?)" message in two particular lines, and I've...
2
6552
by: Paul Reddin | last post by:
Hi, (V8.1 Fp2) Our application uses JDBC batch to execute mutiple insert statements and we saw a strange thing this morning. There were 4 SQL Insert statements in the batch, and we know the...
0
1598
by: Joe Ross | last post by:
(Apologies in advance if there is a better forum for asking advice on this topic). Our ASP.NET application occasionally starts spitting out OutOfMemory exceptions. When this happens, the memory...
16
3919
by: John Salerno | last post by:
Hi all. I just installed Ubuntu and I'm learning how to use the bash shell. Aside from the normal commands you can use, I was wondering if it's possible to use Python from the terminal instead of...
5
2262
by: Johannes Röckert | last post by:
Hi, can anyone help me on how to develop a program in c++ which does single step execution using a callback between the asm commands? I need something like debuggers do - a callback function...
4
7249
by: SPJ | last post by:
Is it possible to run specific commands on cisco router using Python? I have to run command "show access-list" on few hundred cisco routers and get the dump into a file. Please let me know if it is...
3
5094
by: gisto moss | last post by:
i have to implement the shell such that it accepts commands, together with parameters. Assume all possible commands have either 0 or 1 parameter. I need to check this. if(commandstrings.length>2)...
0
7095
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7294
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7015
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7470
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5602
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5026
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3173
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
749
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
403
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.