Created
August 18, 2011 16:52
-
-
Save vermorel/1154507 to your computer and use it in GitHub Desktop.
Email address extraction from Relenta CSV export
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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