Skip to content

Instantly share code, notes, and snippets.

@freiksenet
Forked from kkirsanov/gist:1505942
Created December 22, 2011 09:49
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 freiksenet/1509744 to your computer and use it in GitHub Desktop.
Save freiksenet/1509744 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