Solved

A CSV parser in C#

Posted on 2008-10-06
4
1,336 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
asp.net bundle 8 36
Wpf develop 5 32
C# Error - Add Failed 12 39
install app on other machine 13 11
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.
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the fileā€¦
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

706 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

15 Experts available now in Live!

Get 1:1 Help Now