473,395 Members | 1,666 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Need CSV Parser

Can anyone suggest a good CSV parser that I can use from C#?
I've been using the Ostermiller CSVParser in Java, which is great, but
I can't find a full-featured C# one yet....

I need one that:

- Works for Mac, Windows and Unix end-of-line characters
- Handles fields with end-of-line characters in the middle of it
- Doesn't read the entire file into memory (files can be 100000+
records)
- Runs as managed code

(It'd also be nice if it could read non-latin-1 character sets if
necessary.)

I've found a few freeware ones, but none satisfies all those
requirements. I haven't been able to find a commercial one.

Thanks!

-Mike

Nov 18 '05 #1
4 1603
You can load a csv in as an OLEDB Dataset see this link on for information
on the connection string and let me know if you have any more questions.
http://www.able-consulting.com/MDAC/...CDriverForText
"Mike Bridge" <mi**@bridgecanada.com> wrote in message
news:an********************************@4ax.com...
Can anyone suggest a good CSV parser that I can use from C#?
I've been using the Ostermiller CSVParser in Java, which is great, but
I can't find a full-featured C# one yet....

I need one that:

- Works for Mac, Windows and Unix end-of-line characters
- Handles fields with end-of-line characters in the middle of it
- Doesn't read the entire file into memory (files can be 100000+
records)
- Runs as managed code

(It'd also be nice if it could read non-latin-1 character sets if
necessary.)

I've found a few freeware ones, but none satisfies all those
requirements. I haven't been able to find a commercial one.

Thanks!

-Mike

Nov 18 '05 #2
That may work with a small file, but these CSV files are pretty large
to load whole into a DataSet---some of them will take up over a
megabyte of memory. Since DataSets are connectionless, the ODBC
Driver would either have to either load the whole thing into memory,
which would violate constraint #3, or it would have to somehow copy
and cache the whole file, which would be pretty inefficient.

Also, it looks like you can't open the file without knowing what the
format is in advance, which limits its usefulness. Unless I'm missing
something, it requires a .ini file. Yuck!

And I'm guessing that if it comes from Microsoft, it's Microsoft-only,
and would violate constraint #1.

Thanks for the suggestion, though.

-Mike

On Tue, 11 May 2004 13:40:57 -0400, "Ben Dewey"
<be*******@scientiae.com> wrote:
You can load a csv in as an OLEDB Dataset see this link on for information
on the connection string and let me know if you have any more questions.
http://www.able-consulting.com/MDAC/...CDriverForText
"Mike Bridge" <mi**@bridgecanada.com> wrote in message
news:an********************************@4ax.com.. .
Can anyone suggest a good CSV parser that I can use from C#?
I've been using the Ostermiller CSVParser in Java, which is great, but
I can't find a full-featured C# one yet....

I need one that:

- Works for Mac, Windows and Unix end-of-line characters
- Handles fields with end-of-line characters in the middle of it
- Doesn't read the entire file into memory (files can be 100000+
records)
- Runs as managed code

(It'd also be nice if it could read non-latin-1 character sets if
necessary.)

I've found a few freeware ones, but none satisfies all those
requirements. I haven't been able to find a commercial one.

Thanks!

-Mike


Nov 18 '05 #3
After some further research, I found one which seems to work pretty
well:

http://www.falafelsoft.com/Training/...Parsing_1.aspx

Since it has its own interface for input, I was able to replace its
native StringCharTokenizer class with my own StreamReader-based class,
so it didn't require the whole CSV file to be loaded in memory.

The other problem was that it didn't allow spaces in unquoted strings,
which is pretty common in CSV files. But that's easy to fix, given
the good explanation of the algorigthm on that page.

-Mike

On Tue, 11 May 2004 17:11:29 GMT, Mike Bridge <mi**@bridgecanada.com>
wrote:
Can anyone suggest a good CSV parser that I can use from C#?
I've been using the Ostermiller CSVParser in Java, which is great, but
I can't find a full-featured C# one yet....

Nov 18 '05 #4
Outstanding resource. Thanks Mike.

--
<%= Clinton Gallagher
A/E/C Consulting, Web Design, e-Commerce Software Development
Wauwatosa, Milwaukee County, Wisconsin USA
NET cs*********@REMOVETHISTEXTmetromilwaukee.com
URL http://www.metromilwaukee.com/clintongallagher/

"Mike Bridge" <mi**@bridgecanada.com> wrote in message
news:p1********************************@4ax.com...
After some further research, I found one which seems to work pretty
well:

http://www.falafelsoft.com/Training/...Parsing_1.aspx

Since it has its own interface for input, I was able to replace its
native StringCharTokenizer class with my own StreamReader-based class,
so it didn't require the whole CSV file to be loaded in memory.

The other problem was that it didn't allow spaces in unquoted strings,
which is pretty common in CSV files. But that's easy to fix, given
the good explanation of the algorigthm on that page.

-Mike

On Tue, 11 May 2004 17:11:29 GMT, Mike Bridge <mi**@bridgecanada.com>
wrote:
Can anyone suggest a good CSV parser that I can use from C#?
I've been using the Ostermiller CSVParser in Java, which is great, butI can't find a full-featured C# one yet....


Nov 18 '05 #5

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

Similar topics

0
by: marktm | last post by:
Hi- I am using the following code and want to retrieve an attributes value. I want to loop through the xml file and add the attribute values to an array. The line in question is marked with...
2
by: marktm | last post by:
Hi- I am using the following code and want to retrieve an attributes value. I want to loop through the xml file and add the attribute values to an array. The line in question is marked with...
1
by: Karalius, Joseph | last post by:
Can anyone explain what is happening here? I haven't found any useful info on Google yet. Thanks in advance. mmagnet:/home/jkaralius/src/zopeplone/Python-2.3.5 # make gcc -pthread -c...
3
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...
1
by: Srinivasa Parupalli | last post by:
Dear Friends, I am struck up with logic. I am using one class(BMSLexer) which takes filename as arugument and the instance of the class is used my another class. example is shown below. Now my...
27
by: comp.lang.tcl | last post by:
My TCL proc, XML_GET_ALL_ELEMENT_ATTRS, is supposed to convert an XML file into a TCL list as follows: attr1 {val1} attr2 {val2} ... attrN {valN} This is the TCL code that does this: set...
4
by: ChillyRoll | last post by:
Hello guys, I am looking for a parser in PHP that can return all the attributes of XML entities. I know how to read the XML Entities, but I have got a problem with reading attributes. So I will...
2
by: Anders B | last post by:
I want to make a program that reads the content of a LUA array save file.. More precicely a save file from a World of Warcraft plugin called CharacterProfiler, which dumps alot of information about...
2
by: vijaykk | last post by:
Hi @, I new to java and i am facing
1
by: hellt | last post by:
today i've decided to use optionparser instead of GetOpt and unfortunately i've got an error which i cant handle my pice of code: from optparse import OptionParser def main(): usage =...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
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...

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.