473,804 Members | 3,502 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to open a .CSV file ?

I have a .CSV file (comma delimited) that I want to open using OLEDB, but I
get the error "External table is not in the expected format."
If I save the .CSV file to an .XLS file, I can open the connection with no
problem.
What is the correct way to open a .CSV file ?
If I can not open the CSV file, how can I programmaticall y save the CSV file
to an XLS file ?
Thanks a lot.

dim myCon OleDb.OleDbConn ection
myCon = New OleDbConnection ("Provider=Micr osoft.Jet.OLEDB .4.0; Data
Source=c:\file. csv; Extended Properties=""Ex cel 8.0; HDR=NO; IMEX=1""")
--error "External table is not in the expected format."
Oct 10 '06
22 5011
I have provided a solution that will work. In *some* scenarios your
solution is better (better being defined as more efficient and/or less
involved and/or less prone to exceptions and/or more scalable). In *some*
scenarios my suggestion is better (same definition).

Now, these are all quantifiable things. Can you show me that your solution
is better in all cases in a quantifiable way? Can you do it other that just
saying your right and that I'm an idiot?

If you keep your mind closed then you learn nothing. You have clearly
demonstrated that you have a closed mind (and that's not my opinion - it's a
fact based on your own messages), so I really doubt how much knowledge you
have and how much you can contribute to the discussion.

Good bye & good luck.

"GhostInAK" <pa**@paco.netw rote in message
news:be******** *************** ***@news.micros oft.com...
Hello Scott M.,
>I'm really having trouble understanding why you feel the need to
insult people who have not insulted you?

I don't have any tollerence for idiocy.
>I'm also having difficulty understanding why you haven't bothered to
read any of what I wrote. I know that you haven't, because if you
had, you certainly wouldn't say that by my reasoning every file should
be accessed as a string. How can I know that? Well, because I never
said that. In fact, I said (on more than one occassion) exactly the
opposite (and agreed with you).
>>Why not just use a StreamReader class and parse the values at the
commas?
You can use this technique to parse the file at any character, it
doesn't
have to be the comma.
>>As for the .Split method of a string, it most certainly would serve a
practical purpose [...]
>>we are talking about a file that contains nothing but a string within
it, so using string methods on this string is hardly "stupid".

A string is just a data type that holds a collection of chars.. so all
files are just one big string.
>>[...] but by no means is it the "right" way. The OP said very little
about
the size of the CSV or how complex the data inside it is.

So if one method handles all scenarios, and another doesn't.. and we don't
know what the inputs are.. then yes there is most definately a Right Way
of doing things. String manipulation, in this case, aint it.
>Clearly, you just feel you need to take out some frustration you have
on others. Because any objective person reading what I wrote would
not come to the conclusions you've come to. It sort of sounds like it
doesn't matter what anyone says, you've got the "my way or the
highway" mentality.

Yes.. I feel very frustrated when given a choice between the Right Way and
the Wrong Way, people choose the Wrong Way. I feel frustrated at all
exhibitions of idiocy. This is not to say that idiocy is a permanent
condition. And if people would accept that they were being an idiot for a
moment and then look at the solution provided to correct the situation
their idiocy level would drop dramatically. But no, people cling to being
called an idiot and don't pay attention to the provided solution. "OH MY
GOD! HE CALLED ME AN IDIOT!! What an uncaring bastard!" Hell with you.
Look past being an idiot and look at the solution.

Programming is a form of engineering. It's akin to building any kind of
physical structure. You wouldn't, for example, build a suspension bridge
and then line it with gravel, or build a grass hut in Fairbanks, Alaska.
You could certainly do these things, but if the goal is to build a vehicle
bridge that will last 100s of years, or a domicile for humans to live in,
these are Wrong things to do. The same goes for programming. Just
because something "works" (oh look, the grass hut is livable! It's sunny
and 80 degrees out!) doesnt mean it's the Right Thing (oh crap, its
February and -45 degrees.. and I'm dead because my grass hut wont hold
heat).

-Boo


Oct 13 '06 #21
By the way, you should take a look at this:

http://www.devarticles.com/c/a/ASP.N...et-and-VB.Net/

and then you should contact: G Ajaykumar (aj*********@co olgoose.com) to
tell him that he is an idot and that he should go "to hell" for having the
odassity to suggest the exact same thing I did. Only he is worse than I am
because he posted it at the very popular and widely regarded web site
http://ASP.net.

In fact, you should really block off some time to spread the word about all
the idiots out there because most of the suggestions on solving this problem
suggest either a StreamReader or some variation of that.

http://www.google.com/search?sourcei...2ecsv+vb%2enet

To make matters worse, there are actually many developers out there
suggesting the "wrong" course of action on escaping out any trouble
characters in the .csv in the same manner that I suggested.

Yes, now I see the error of my ways. I may be an idot, but at least I'm in
good company AND fortunately, you are in that same group


"GhostInAK" <pa**@paco.netw rote in message
news:be******** *************** ***@news.micros oft.com...
Hello Scott M.,
>I'm really having trouble understanding why you feel the need to
insult people who have not insulted you?

I don't have any tollerence for idiocy.
>I'm also having difficulty understanding why you haven't bothered to
read any of what I wrote. I know that you haven't, because if you
had, you certainly wouldn't say that by my reasoning every file should
be accessed as a string. How can I know that? Well, because I never
said that. In fact, I said (on more than one occassion) exactly the
opposite (and agreed with you).
>>Why not just use a StreamReader class and parse the values at the
commas?
You can use this technique to parse the file at any character, it
doesn't
have to be the comma.
>>As for the .Split method of a string, it most certainly would serve a
practical purpose [...]
>>we are talking about a file that contains nothing but a string within
it, so using string methods on this string is hardly "stupid".

A string is just a data type that holds a collection of chars.. so all
files are just one big string.
>>[...] but by no means is it the "right" way. The OP said very little
about
the size of the CSV or how complex the data inside it is.

So if one method handles all scenarios, and another doesn't.. and we don't
know what the inputs are.. then yes there is most definately a Right Way
of doing things. String manipulation, in this case, aint it.
>Clearly, you just feel you need to take out some frustration you have
on others. Because any objective person reading what I wrote would
not come to the conclusions you've come to. It sort of sounds like it
doesn't matter what anyone says, you've got the "my way or the
highway" mentality.

Yes.. I feel very frustrated when given a choice between the Right Way and
the Wrong Way, people choose the Wrong Way. I feel frustrated at all
exhibitions of idiocy. This is not to say that idiocy is a permanent
condition. And if people would accept that they were being an idiot for a
moment and then look at the solution provided to correct the situation
their idiocy level would drop dramatically. But no, people cling to being
called an idiot and don't pay attention to the provided solution. "OH MY
GOD! HE CALLED ME AN IDIOT!! What an uncaring bastard!" Hell with you.
Look past being an idiot and look at the solution.

Programming is a form of engineering. It's akin to building any kind of
physical structure. You wouldn't, for example, build a suspension bridge
and then line it with gravel, or build a grass hut in Fairbanks, Alaska.
You could certainly do these things, but if the goal is to build a vehicle
bridge that will last 100s of years, or a domicile for humans to live in,
these are Wrong things to do. The same goes for programming. Just
because something "works" (oh look, the grass hut is livable! It's sunny
and 80 degrees out!) doesnt mean it's the Right Thing (oh crap, its
February and -45 degrees.. and I'm dead because my grass hut wont hold
heat).

-Boo


Oct 13 '06 #22
Correction:

....AND fortunately, you are NOT in that same group.

"Scott M." <s-***@nospam.nosp amwrote in message
news:Og******** ******@TK2MSFTN GP03.phx.gbl...
By the way, you should take a look at this:

http://www.devarticles.com/c/a/ASP.N...et-and-VB.Net/

and then you should contact: G Ajaykumar (aj*********@co olgoose.com) to
tell him that he is an idot and that he should go "to hell" for having the
odassity to suggest the exact same thing I did. Only he is worse than I
am because he posted it at the very popular and widely regarded web site
http://ASP.net.

In fact, you should really block off some time to spread the word about
all the idiots out there because most of the suggestions on solving this
problem suggest either a StreamReader or some variation of that.

http://www.google.com/search?sourcei...2ecsv+vb%2enet

To make matters worse, there are actually many developers out there
suggesting the "wrong" course of action on escaping out any trouble
characters in the .csv in the same manner that I suggested.

Yes, now I see the error of my ways. I may be an idot, but at least I'm
in good company AND fortunately, you are in that same group


"GhostInAK" <pa**@paco.netw rote in message
news:be******** *************** ***@news.micros oft.com...
>Hello Scott M.,
>>I'm really having trouble understanding why you feel the need to
insult people who have not insulted you?

I don't have any tollerence for idiocy.
>>I'm also having difficulty understanding why you haven't bothered to
read any of what I wrote. I know that you haven't, because if you
had, you certainly wouldn't say that by my reasoning every file should
be accessed as a string. How can I know that? Well, because I never
said that. In fact, I said (on more than one occassion) exactly the
opposite (and agreed with you).
>>>Why not just use a StreamReader class and parse the values at the
commas?
You can use this technique to parse the file at any character, it
doesn't
have to be the comma.
>>>As for the .Split method of a string, it most certainly would serve a
practical purpose [...]
>>>we are talking about a file that contains nothing but a string within
it, so using string methods on this string is hardly "stupid".

A string is just a data type that holds a collection of chars.. so all
files are just one big string.
>>>[...] but by no means is it the "right" way. The OP said very little
about
the size of the CSV or how complex the data inside it is.

So if one method handles all scenarios, and another doesn't.. and we
don't know what the inputs are.. then yes there is most definately a
Right Way of doing things. String manipulation, in this case, aint it.
>>Clearly, you just feel you need to take out some frustration you have
on others. Because any objective person reading what I wrote would
not come to the conclusions you've come to. It sort of sounds like it
doesn't matter what anyone says, you've got the "my way or the
highway" mentality.

Yes.. I feel very frustrated when given a choice between the Right Way
and the Wrong Way, people choose the Wrong Way. I feel frustrated at all
exhibitions of idiocy. This is not to say that idiocy is a permanent
condition. And if people would accept that they were being an idiot for
a moment and then look at the solution provided to correct the situation
their idiocy level would drop dramatically. But no, people cling to
being called an idiot and don't pay attention to the provided solution.
"OH MY GOD! HE CALLED ME AN IDIOT!! What an uncaring bastard!" Hell
with you. Look past being an idiot and look at the solution.

Programming is a form of engineering. It's akin to building any kind of
physical structure. You wouldn't, for example, build a suspension bridge
and then line it with gravel, or build a grass hut in Fairbanks, Alaska.
You could certainly do these things, but if the goal is to build a
vehicle bridge that will last 100s of years, or a domicile for humans to
live in, these are Wrong things to do. The same goes for programming.
Just because something "works" (oh look, the grass hut is livable! It's
sunny and 80 degrees out!) doesnt mean it's the Right Thing (oh crap,
its February and -45 degrees.. and I'm dead because my grass hut wont
hold heat).

-Boo



Oct 13 '06 #23

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

Similar topics

1
4119
by: yanivmad | last post by:
hi I like to ask if there any option to control the html files?!? I have some HTML files at my web site that use one "Help.htm" file for all the pages {I use the "window.open(.... " option at JS }, and I like to open only one file every time for all the files. I use "myFunc.js" javascript file for all the files that try to open the "Help.htm" file so I hava an 'Object' that hold the
9
13431
by: Charles F McDevitt | last post by:
I'm trying to upgrade some old code that used old iostreams. At one place in the code, I have a path/filename in a wchar_t string (unicode utf-16). I need to open an ifstream to that file. But the open() on ifstream only takes char * strings (mbcs?). In old iostreams, I could _wopen() the file, get the filedesc, and call attach() on the ifstream.
6
56000
by: Dino Buljubasic | last post by:
My application creates some temporary files that are deleted when my application terminates. However, if a temp file is open, it will not be deleted and application will crash. How can I check if a file is open before deleting it Something like this
2
6159
by: Mattbooty | last post by:
Hello, Not sure if anyone else has seen this bug, but I have a form where the entire form is covered with a picturebox. The picturebox has a mouseup event. I also have an open file dialog for loading images into the picturebox. If you double click the file you want to open in the open file dialog, it somehow interperets one of the clicks as a mouseup on the picturebox and fires the mouseup event for the picturebox. How can I get...
6
10037
by: qysbc | last post by:
I have a web page and there is a link to open a TIFF file. The way I do it is to have the server code open a binary stream, set the content type to "image/tiff" and call Response.BinaryWrite. On the client machine, the file type TIFF is associated with Kodak Imaging Preview. This app works on most client machines. When you click on the link, Kodak Imaging Preview will open the TIFF file on the client machine. However, on some machines, the...
2
4426
by: OutdoorGuy | last post by:
Greetings, I have a "newbie" question in relation to opening files from C#. I have a Windows form where I allow the user to type in a file extension in a text box (e.g., "xls"). I then take that extension and use that as my filter criteria for the File Open dialog. Once the user selects a file with that extension (from the File Open dialog), I simply want to open that file (whether it is an .xls file, .txt file, etc.). I am...
6
3112
by: Moumen VB.NET 2003/2005 Developer | last post by:
How can I detect if a file sitting on a network drive is still open by another application? This application resides on another machine on the network? I am using VB.NET 2003 Your help is highly appreciated
5
11226
by: Ryan Liu | last post by:
Hi, Both way works, I'd just ask some experts which way is better? My application creates a log file daily. Now each time when I write a log, I will open the file and append to the end. Ocz, if the file is not exist(e.g. another day), it will creates the file first.
6
34659
by: Ros | last post by:
There are 10 files in the folder. I wish to process all the files one by one. But if the files are open or some processing is going on them then I do not want to disturb that process. In that case I would ignore processing that particular file and move to next file. How can I check whether the file is open or not? I tried os.stat and os.access but I am not getting the expected results. Also I checked in IO exceptions, IO error handler...
0
2675
by: Ofelia | last post by:
Hi, I'm new to this forum and to Perl language but I would like to ask for your help. I'm working in Linux and the files I need to process are in the format “file.gz”. I created a script which should decompress, open and then delete nearly 400 files. To do so I use "open FILEPT, "zcat $filename|"". In the beginning the script works fine, but after about 300 files processed I get an error on Open function: “proc: Could not open file...
0
9571
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10561
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10069
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9132
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6845
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5639
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4277
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3803
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2976
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.