Skip to content

Instantly share code, notes, and snippets.

@kkirsanov
Created December 21, 2011 12:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kkirsanov/1505942 to your computer and use it in GitHub Desktop.
Save kkirsanov/1505942 to your computer and use it in GitHub Desktop.
import Data.List
infinityString st = st ++ infinityString st
split :: String->Char->[String]
split [] ch = []
split st ch = start : split ending ch where
(start, e) = break (==ch) st
ending = drop 1 e
parseCSV t = mails where
lines = split t '\n'
tabbed = map (`split` '\t') lines
col = map (!!3) tabbed
filtered1 = map (filter ( /='\"')) col
filtered2 = filter (elem '@') filtered1
mails = filtered2
main = do
text <- readFile "data.csv"
mapM_ putStrLn (parseCSV text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment