473,804 Members | 2,986 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Parser for CSV files

Hi,

Is there a parser which parses CSV files?

Thanks for your help.
Reza
Nov 16 '05 #1
25 12765
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

Nov 16 '05 #2
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


Nov 16 '05 #3
There's loads of CSV parsers out there:

http://www.google.co.uk/search?sourc...sv+parser+c%23

Good luck.

"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



Nov 16 '05 #4
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

Nov 16 '05 #5
k
I ended up writing a CSV parser based upon the Microsoft.Jet.O LEDB.4.0
driver, which I use all the time! It's not hard and you can then build
the validator(s) as a seperate component.

Kirsty

Nov 16 '05 #6
Thanks for your help
"Dan Bass" <Not Listed> wrote in message
news:eW******** ******@TK2MSFTN GP14.phx.gbl...
There's loads of CSV parsers out there:

http://www.google.co.uk/search?sourc...sv+parser+c%23

Good luck.

"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



Nov 16 '05 #7
Excellent ,very nice idea.here is some questions in regards to your
solution:

1) you said :
use ADO.NET to read/write a CSV file via, say, a generic text ODBC driver
or the Excel driver What do yuo mean by a generic text ODBC driver or the Excel driver?

2)I didn't underestand what's the usage of And a FieldInfo property consisting of an arraylist of FieldInfo structs
that defines the field name/data type of each field.
3)I need to validate each record value against some complicated rules ,what
have you done about that?

4) Can you send me that example by any chance?
my email is Fa**********@ya hoo.com (remove Fake from the beggining of my
userid:-)

Thanks very much for your nice help.

Ali


"Bob Grommes" <bo*@bobgrommes .com> wrote in message
news:un******** ******@TK2MSFTN GP15.phx.gbl... 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


Nov 16 '05 #8
Hi,

Take a look at www.opennetcf.org they provide one free with source code,
I'm using it and works great

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"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

Nov 16 '05 #9
Where is it ? I can't find it there.

Thanks for your help.
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.mach in AT dot.state.fl.us > wrote
in message news:%2******** **********@TK2M SFTNGP10.phx.gb l...
Hi,

Take a look at www.opennetcf.org they provide one free with source code,
I'm using it and works great

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"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


Nov 16 '05 #10

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

Similar topics

1
2639
by: Bob Bedford | last post by:
I've a function asking for a $_FILES argument: function insertarticle($particle,......,$pUserID,$pOptions,$files){ in this function I do add the record and then save the files in a subdirectory specific on some datas. This function is used by my "insert" form, letting the user to select images files to upload with <FILE> html tag. The files to upload are then passed to the $files like this:...
3
3125
by: Himanshu Garg | last post by:
Hello, I am trying to pinpoint an apparent bug in HTML::Parser. The encoding of the text seems to change incorrectly if the locale isn't set properly. However Parser.pm in the directory (/usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi/HTML/) doesn't seem to contain the "real" parsing statements.
3
1967
by: cr88192 | last post by:
for various reasons, I added an imo ugly hack to my xml parser. basically, I wanted the ability to have binary payload within the xml parse trees. this was partly because I came up with a binary xml format (mentioned more later), and thought it would be "useful" to be able to store binary data inline with this format, and still wanted to keep things balanced (whatever the binary version can do, the textual version can do as well). the...
5
2639
by: qqcq6s59 | last post by:
Hi all I am a newbie and I just saw a ongoing thread on Fileprocessing which talks abt config parser. I have writen many pyhton program to parse many kind of text files by using string module and regex. But after reading that config parser thread I feel stunned. Can somebody tell me some intro info how to parse huge data (most of them are input data to application softwares like nastran, abaqus etc)
4
3091
by: billcoumbe | last post by:
any recommendations? I'm looking for something that will just run from the unix command line to validate large (20-50Mb) XML files against an XML DTD. Ideally something that is actively supported and has good documentation! If there's nothing suitable for Solaris a command line program for Windows might do - currently using XMetaL/XMLSpy parsers which aren't really suited to large files.
2
4554
by: news.microsoft.com | last post by:
Hi: I work in Csharp's parser files by LEX/YACC.Now I have only CSharp-lex.l and CSharp.y file,but they not have CSharp'comment Parse. this is a part of CSharp-lex.l. ..................... /***** Comments *****/ "/*" { yy_push_state(IN_COMMENT); } <IN_COMMENT>. { ; /* ignore */ } <IN_COMMENT>\n { ; /* ignore */ }
6
3890
by: ST | last post by:
Hi, I keep getting the parser error, and I have no idea why. I've tried a number of things including: 1)building/rebuilding about 100x 2)making sure all dll's are in the bin folder in the root of the web app 3)restarting IIS 4)recreating the virtual dir in IIS 5)playing with any and all settings I could find for the web app in IIS, including changing permissions 6)recopying the machineconfig file from my asp v1.4... onto my local server
0
376
by: Bob Bedford | last post by:
Hi all, I've to parse XML files on the fly and I must admit I'm far away to understand why the parser are done. The files I receive have all the same structure, and due to limitations of my hosting (I can't change, so don't tell me to) I have a 10 seconds script limit. My XML files contains datas and images.
0
2244
by: UncleRic | last post by:
Environment: Mac OS X (10.4.10) on MacBook Pro I'm a Perl Neophyte. I've downloaded the XML::Parser module and am attempting to install it in my working directory (referenced via PERL5LIB env): PERL5LIB=/Users/Ric/Library/Perl/ ls XML-Parser-2.34/ XML-Parser-2.34.tar
18
4733
by: Just Another Victim of the Ambient Morality | last post by:
Is pyparsing really a recursive descent parser? I ask this because there are grammars it can't parse that my recursive descent parser would parse, should I have written one. For instance: from pyparsing import * grammar = OneOrMore(Word(alphas)) + Literal('end') grammar.parseString('First Second Third end')
0
9579
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
10578
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
10332
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10321
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
6853
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
5522
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...
0
5651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3820
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2991
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.