Nothing built-in for this. The two solutions most commonly given to this
question is to use String.Spit() (too simplistic for general use; it doesn't
handle field values that are quoted and have a comma within them, for
instance) ... or, use ADO.NET to read/write a CSV file via, say, a generic
text ODBC driver or the Excel driver. The ADO.NET solution has the downside
of configuration issues to iron out, and I believe a 254 field limit in some
cases. Particularly if deployment will be on many arbitrary machines, you
have to worry about whether your chosen drive is installed, what version it
is, etc. It does make life more complicated and finicky.
Since I read and write a variety of CSV and CSV-like formats all the time
(pipe-delimited, tab-delimited, space-delimited, and various bizarre formats
such as field label....value, one field to a line, and even scraping of text
reports), I've found it much more efficient and trouble free to write my own
classes for this purpose. For example I have a DelimitedTextFi le() class
whose constructor takes a file name (or a FileInfo instance), that has a
ReadRecord() method that returns an arraylist of record values, and a
WriteRecord() method that takes an arraylist of values and writes them out.
And a FieldInfo property consisting of an arraylist of FieldInfo structs
that defines the field name/data type of each field. All of this works very
fast and has proven to be highly adaptable to anything that gets thrown at
it.
--Bob
"Ali-R" <Al**@microsft. com> wrote in message
news:u0******** ******@TK2MSFTN GP12.phx.gbl...
No,I'm getting a CSV file from a client and I need to open it up and do
some checks on it it before handing it over to another programme.I'm
looking for something similar to get some ideas how to pars a CSV file in
the most efficient way.
Thanks for your quick help.
"saurabh" <sa*****@nagpur city.net> wrote in message
news:OL******** ******@TK2MSFTN GP12.phx.gbl... you mean something like String.split() on a comma ??
--Saurabh
"Ali-R" <Al**@microsft. com> wrote in message
news:eE******** ******@TK2MSFTN GP10.phx.gbl... Hi,
Is there a parser which parses CSV files?
Thanks for your help.
Reza