Solved

A CSV parser in C#

Posted on 2008-10-06
4
1,363 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

How our DevOps Teams Maximize Uptime

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

Question has a verified solution.

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

With mobile becoming increasingly important to the business world, it is in your best interest to make sure that your email signature looks great across all types of devices. Find out how to create a mobile email signature with this guide.
The 21st century solution to antiquated pagers.
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

734 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