Skip to content

Instantly share code, notes, and snippets.

@vermorel
Created August 18, 2011 16:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vermorel/1154507 to your computer and use it in GitHub Desktop.
Save vermorel/1154507 to your computer and use it in GitHub Desktop.
Email address extraction from Relenta CSV export
// The CSV file produced by Relenta while exporting contact is somewhat messy.
// Using this tiny app to extract the first email address of each contact.
using System;
using System.IO;
namespace ConsoleTest
{
class Program
{
static void Main(string[] args)
{
var filename = "relenta_lokad.com_08-18-11_18-34.csv";
var reader = new StreamReader(filename);
string line;
while ((line = reader.ReadLine()) != null)
{
var tokens = line.Split(new[] {",", ";", "\"", " ", "(", ")", "<", ">" }, StringSplitOptions.RemoveEmptyEntries);
foreach (var t in tokens)
{
if (t.Contains("@") && t.Contains(".")
&& !t.Contains("+")
&& !t.Contains("lokad.com") && !t.Contains("twitter.com") && !t.Contains("paypal"))
{
Console.WriteLine(t);
break;
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment