Re: How to open a .CSV file ?



Hello Scott M.,

Wow.. I've been such a fool.. it's taken your inspired words to make me see the light.

I suppose by your reasoning every file is just a big long string and we should all be using the string manipulation functions to work with them. Yer bein an ass. Just admit when yer wrong.

-Boo

(really trying to avoid a flame war) Scott M. writes:

With all due respect, your suggested way is great (and may even be the
"better" way in this scenario), 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. Without knowing the answers to those questions, it
would be foolish to suggest what the "right" way to proceed would be.

May I suggest that if you believe that using String methods to parse a
string is "amature", you may be a bit closed minded to other
programming possibilites. There is never just one correct way to
solve a programmatic problem.

If you would take your blinders off, you might realize that different
scenarios require different approaches.

Good luck.

"GhostInAK" <paco@xxxxxxxx> wrote in message
news:c71747b44b1e38c8bb92a18c9900@xxxxxxxxxxxxxxxxxxxxx

Hello Scott M.,

Well, you can do it the amature way or you can do it the right way.
Matters not to me - I won't ever be using any of the crap you write.
The OP had it right, even if the details were buggered. The correct
way
to work with CSV files in .NET is vial the OleDb namespace. Any
other
home-grown hand-rolled crap is wasted effort.
-Boo

And, by the way. we are talking about a file that contains nothing
but a string within it, so using string methods on this string is
hardly "stupid".

"GhostInAK" <paco@xxxxxxxx> wrote in message
news:be1391bf1c5218c8bb6e9594ebe3@xxxxxxxxxxxxxxxxxxxxx
Hello Scott M.,

Well, yes, you could write your own CSV parser as MDO did.. but
that would serve no practical purpose other than to teach you how
to write a string parser.

I assume when you said "parse at the comma" you meant string.split.
While you could use this function, it would be stupid to use it on
a CSV file. Quoted values are going to kill you. It's not worth
it.

-Boo

You can use this technique to parse the file at any character, it
doesn't have to be the comma.

"GhostInAK" <paco@xxxxxxxx> wrote in message
news:be1391bf1c1ee8c8ba8d6a850af6@xxxxxxxxxxxxxxxxxxxxx
Hello Scott M.,

Because not all CSV files are supposed to be parsed at the comma:
Value One, "Value, Two", Value Three

OP, your connection string is wrong. Try:
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\;Extended
Properties=Text;

-Boo

Why not just use a StreamReader class and parse the values at
the commas?

"fniles" <fniles@xxxxxxxxxx> wrote in message
news:%23pruw%23K7GHA.4708@xxxxxxxxxxxxxxxxxxxxxxx
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 programmatically save
the
CSV
file to an XLS file ?
Thanks a lot.
dim myCon OleDb.OleDbConnection
myCon = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;
Data
Source=c:\file.csv; Extended Properties=""Excel 8.0; HDR=NO;
IMEX=1""")
--> error "External table is not in the expected format."


.



Relevant Pages

  • Re: How to open a .CSV file ?
    ... string is "amature", you may be a bit closed minded to other programming ... I assume when you said "parse at the comma" you meant string.split. ... If I save the .CSV file to an .XLS file, ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Inconsistency of Export to a CSV file.
    ... A CSV file is a txt file with a different extension. ... >>Public Sub ExportDelim(strTable As String, ... >> Dim varData As Variant ... >> Dim intFileNum As Integer ...
    (microsoft.public.access.externaldata)
  • Re: How to open a .CSV file ?
    ... character) could be escaped before any parsing took place. ... it wold split the string at whatever character it is told ... I assume when you said "parse at the comma" you meant string.split. ... it would be stupid to use it on a CSV file. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: type conversion error
    ... Take a look to the missing data in your csv file so you can understand why ... ByVal HDR As Boolean) As String ... Dim strFolder As String ... Dim strFileName As String ...
    (microsoft.public.access.modulesdaovba)
  • Re: How to open a .CSV file ?
    ... string within it, so using string methods on this string is hardly "stupid". ... I assume when you said "parse at the comma" you meant string.split. ... it would be stupid to use it on a CSV file. ... If I save the .CSV file to an .XLS file, ...
    (microsoft.public.dotnet.languages.vb)