By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,939 Members | 1,600 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,939 IT Pros & Developers. It's quick & easy.

Need CSV Parser

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.