Solved

A CSV parser in C#

Posted on 2008-10-06
4
1,340 Views
Last Modified: 2013-12-17
Hello

Can someone please help me with a parser in C# for retrieving email addresses in a  CSV file
The CSV file could be from Microsoft Outlook or a Palm Desktop

thanks
0
Comment
Question by:jbajaj
  • 3
4 Comments
 
LVL 5

Expert Comment

by:sciphre
ID: 22653832
I'm pretty sure that you can find a fast C# CSV parser in the .NET library, but if you don't want to use .NET libraries this looks like a good solution:

http://www.codeproject.com/KB/recipes/Basic_CSV_Parser_Function.aspx
0
 
LVL 5

Expert Comment

by:sciphre
ID: 22653842
Actually scratch that, looks like an educational solution, here, this is the real thing:

http://www.filehelpers.com/
0
 
LVL 14

Expert Comment

by:Ramuncikas
ID: 22656879
If you need JUST email addresses (no names, phones, etc.) the the simplest solution would be:
1. read csv file into string
2. user Regex to extract email addresses.

If you're interested I could pass you some sample code.

R
0
 
LVL 5

Accepted Solution

by:
sciphre earned 500 total points
ID: 22656953
The Microsoft Outlook csv file contains 92 (!) fields.
Don't homebrew a parser, it will bite you in the fleshy part of your back side many times over as you try to maintain it.

Look at it this way: if you make a small regex to extract email addresses (which you will not get right on first try), and at some point someone decides they also want to extract names, you need to rewrite the whole thing.
Learn how to use a .Net library (filehelper) to map CSV - next time you need to add or remove a field you just copy over the field name into the output section.
And since the whole thing is already implemented, debugged and interfaced, it's really easier to use than any homebrew, no matter how good you are.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Everyone is using a smartphone these days. Contacts, messages, applications, documents, bookmarks, pictures, videos and other stuff which you created and are present only on your device come under the umbrella called “Personal Data”.…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
A short film showing how OnPage and Connectwise integration works.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

930 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now