473,804 Members | 2,962 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
Well, not really. Quoted values (and single quotes and any other special
character) could be escaped before any parsing took place.

As for the .Split method of a string, it most certainly would serve a
practical purpose, it wold split the string at whatever character it is told
to. The fact is that we are talking about a delimited file here and that
means that the delimeter is a known character - this is exactly what
..split() is for.

Now, I grant you that if the CSV is a large file, then a StreamReader and
the .split() method are probably not the most efficient approach, but the OP
didn't indicate it was a large file.

Other than the file size, there is no reason why reading the file contents
in, escaping any trouble characters and parsing the string at the delimeter
wouldn't work just fine.


"GhostInAK" <pa**@paco.netw rote in message
news:be******** *************** ***@news.micros oft.com...
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" <pa**@paco.netw rote in message
news:be******* *************** ****@news.micro soft.com...
>>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=Micr osoft.Jet.OLEDB .4.0;Data Source=c:\;Exte nded
Properties=Te xt;

-Boo

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

"fniles" <fn****@pfmail. comwrote in message
news:%2***** *************@T K2MSFTNGP05.phx .gbl...
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:\f ile.csv; Extended Properties=""Ex cel 8.0; HDR=NO;
IMEX=1""" )
--error "External table is not in the expected format."


Oct 12 '06 #11
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" <pa**@paco.netw rote in message
news:be******** *************** ***@news.micros oft.com...
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" <pa**@paco.netw rote in message
news:be******* *************** ****@news.micro soft.com...
>>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=Micr osoft.Jet.OLEDB .4.0;Data Source=c:\;Exte nded
Properties=Te xt;

-Boo

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

"fniles" <fn****@pfmail. comwrote in message
news:%2***** *************@T K2MSFTNGP05.phx .gbl...
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:\f ile.csv; Extended Properties=""Ex cel 8.0; HDR=NO;
IMEX=1""" )
--error "External table is not in the expected format."


Oct 12 '06 #12
Because my clients send me text files, many of which can be quickly and
simply parsed by this code and it's a lot faster than coding up a database
for each client. Also, if you had READ my comments about the code and knew
ANYTHING at all about VB 6, you'd know that there is NO SUCH THING as
System.Data.Ole Db in VB 6. Yes, I could have used the VB 6 Excel Text
parser, but it isn't nearly as flexible as expected.

Mike.

"GhostInAK" <pa**@paco.comw rote in message
news:c7******** *************** ***@news.micros oft.com...
Hello Michael,
Why in the name of all that is evil and holy would anyone use THAT CRAP
instead
of a datatable and the System.Data.Ole Db namespace.
It's not a question. No answer is required. Fuckin amature crackheads.

-Boo
Here's a CSVLine class that I developed for this very purpose. It's
not elegant, but it works. It was originally written in VB 6, so it
still uses the VB Collection object instead of .NET framework
collections. You can create an object in one of two methods:

dim csv as new CSVLine
dim csv as new CSVLine(line as string, headers() as string)
The first method allows you to create a csv line from scratch and use
the ToString method to generate an Excel compatible csv line for
writing to a file.

The second method takes an excel compatible line and an array of
header strings and allows you to reference the contents of the line by
index name

dim headers() as string = split("H1,H2,H3 ", ",")
dim line as string = """"Header, 1""",Header 2,"""Header 3""""
dim csv as new CSVLine(line, headers)
Debug.Print csv("H1") ' Returns without quotes "Header, 1"

Although there may be an Excel compatible CSV file that this class
can't parse, I haven't run across it in several years of using this
class, first in VB 6 and now in VB 2005.

Hope this helps,
Mike Ober.
=============== ========
Option Compare Text
Option Explicit On
Option Strict On
Public Class csvLine
Dim cRecs As New Collection
Public Sub New()
End Sub
Public Sub New(ByVal Line As String, ByVal Keys() As String,
Optional
ByVal delim As String = ",")
Dim temp As String
Dim tKey As String
Dim i As Integer
Dim InQuotes As Boolean
Dim c As String = ""
Dim j As Integer
For i = LBound(Keys) To UBound(Keys)
InQuotes = False
temp = ""
If Len(Line) 0 Then
c = Left$(Line, 1)
Do While Len(Line) 0
Line = Mid$(Line, 2)
Select Case c
Case """"
InQuotes = Not InQuotes
Case delim
If Not InQuotes Then
c = ""
Exit Do
End If
End Select
temp = temp & c
c = Left$(Line, 1)
Loop
End If
' Append final character
temp = temp & c
' Remove leading and trailing Quotes
Select Case Len(temp)
Case 0
Case 1
If temp = """" Then temp = ""
If temp = delim Then temp = ""
Case Else
If Left$(temp, 1) = """" And Right$(temp, 1) =
"""" Then
temp = Mid$(temp, 2, Len(temp) - 2)
End Select
' Replace Double Quotes from string with Single Quotes
j = 1
Do While Len(temp) 0 And j < Len(temp) And j 0
j = InStr(j, temp, """""")
If j 0 Then
temp = Left$(temp, j - 1) & Mid$(temp, j + 1)
End If
Loop
' Associate value with column name
tKey = Keys(i)
j = 0
Do While cRecs.Contains( tKey)
j = j + 1
tKey = Keys(i) & "_" & j
Loop
cRecs.Add(temp, tKey)
Next i
End Sub
Public Sub Add(ByVal obj As Object, ByVal Key As String)
cRecs.Add(obj, Key)
End Sub
Public Sub Add(ByVal obj As Object)
cRecs.Add(obj)
End Sub
Default Public ReadOnly Property Item(ByVal index As String) As
String
Get
If cRecs.Contains( index) Then Return cRecs(index).To String
'Debug.Assert(F alse, "Unknown index: " & index)
Return Nothing
End Get
End Property
Public Shadows Function ToString(Option al ByVal Delim As String =
",")
As String
Dim i As Integer
Dim sOut As String = ""
For i = 1 To cRecs.Count - 1
If IsNumeric(cRecs (i)) Then
sOut = sOut & Trim(cRecs(i).T oString) & Delim
Else
sOut = sOut & """" & cRecs(i).ToStri ng & """" & Delim
End If
Next i
If IsNumeric(cRecs (i)) Then
sOut = sOut & Trim(Str(cRecs( i)))
Else
sOut = sOut & """" & cRecs(i).ToStri ng & """"
End If
Return sOut
End Function
End Class
"GhostInAK" <pa**@paco.netw rote in message
news:be******** *************** ***@news.micros oft.com...
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=Micros oft.Jet.OLEDB.4 .0;Data
Source=c:\;Exte nded Properties=Text ;

-Boo

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

"fniles" <fn****@pfmail. comwrote in message
news:%2******* ***********@TK2 MSFTNGP05.phx.g bl...
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:\fil e.csv; Extended Properties=""Ex cel 8.0; HDR=NO;
IMEX=1""")
--error "External table is not in the expected format."




Oct 12 '06 #13
set the extended properties to 'text' for csv file and remember to create the ini file for field definition
"fniles" <fn****@pfmail. comwrote in message news:%2******** **********@TK2M SFTNGP05.phx.gb l...
>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 12 '06 #14
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" <pa**@paco.netw rote in message
news:be******** *************** ***@news.micros oft.com...
>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" <pa**@paco.netw rote in message
news:be****** *************** *****@news.micr osoft.com...
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=Mic rosoft.Jet.OLED B.4.0;Data Source=c:\;Exte nded
Properties=T ext;

-Boo

Why not just use a StreamReader class and parse the values at the
commas?
>
"fniles" <fn****@pfmail. comwrote in message
news:%2**** **************@ TK2MSFTNGP05.ph x.gbl...
>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
>connecti on
>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 12 '06 #15
(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" <pa**@paco.comw rote in message
news:c7******** *************** ***@news.micros oft.com...
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" <pa**@paco.netw rote in message
news:be******* *************** ****@news.micro soft.com...
>>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 " <pa**@paco.netw rote in message
news:be***** *************** ******@news.mic rosoft.com...
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=Mi crosoft.Jet.OLE DB.4.0;Data Source=c:\;Exte nded
Properties= Text;
>
-Boo
>
>Why not just use a StreamReader class and parse the values at the
>commas?
>>
>"fniles" <fn****@pfmail. comwrote in message
>news:%2*** *************** @TK2MSFTNGP05.p hx.gbl...
>>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
>>connectio n
>>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 12 '06 #16
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" <pa**@paco.comw rote in message
news:c7******** *************** ***@news.micros oft.com...
>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" <pa**@paco.netw rote in message
news:be****** *************** *****@news.micr osoft.com...
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.
>
"GhostInA K" <pa**@paco.netw rote in message
news:be**** *************** *******@news.mi crosoft.com...
>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=M icrosoft.Jet.OL EDB.4.0;Data Source=c:\;Exte nded
>Properties =Text;
>>
>-Boo
>>
>>Why not just use a StreamReader class and parse the values at
>>the commas?
>>>
>>"fniles " <fn****@pfmail. comwrote in message
>>news:%2** *************** *@TK2MSFTNGP05. phx.gbl...
>>>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
>>>connecti on
>>>with no
>>>proble m.
>>>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 12 '06 #17
I'm really having trouble understanding why you feel the need to insult
people who have not insulted you?

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).

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.

Good luck with that.
"GhostInAK" <pa**@paco.netw rote in message
news:be******** *************** ***@news.micros oft.com...
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" <pa**@paco.comw rote in message
news:c7******* *************** ****@news.micro soft.com...
>>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 " <pa**@paco.netw rote in message
news:be***** *************** ******@news.mic rosoft.com...
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 " <pa**@paco.netw rote in message
>news:be*** *************** ********@news.m icrosoft.com...
>>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.O LEDB.4.0;Data Source=c:\;Exte nded
>>Propertie s=Text;
>>>
>>-Boo
>>>
>>>Why not just use a StreamReader class and parse the values at
>>>the commas?
>>>>
>>>"fnile s" <fn****@pfmail. comwrote in message
>>>news:%2* *************** **@TK2MSFTNGP05 .phx.gbl...
>>>>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
>>>>connect ion
>>>>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 ?
>>>>Thank s 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 12 '06 #18
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 #19
Boo,

In my opinion is it mostly an idiot who calls an other an idiot.

At least you can hide your less of knowledge behind that.

If you want to show that somebody is an idiot, than proof why, but don't
tell it.

In my eyes you are surely not an idiot, before you would read this in this
message.

Please keep it like that.

About the content of your message, again a prase.

There are more roads that goes to Rome.

The direction from which you come tells which is the best.
Don't tell another one who comes from a complete different direction that
only your road is the best.

Just some opinions from an "Idiot" who still is trying to help.

Cor

"GhostInAK" <pa**@paco.nets chreef in bericht
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 #20

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
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...
1
10302
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
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...
1
7608
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5505
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
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.