Created
February 8, 2015 10:49
-
-
Save takapiko/ac08422833fa09d92510 to your computer and use it in GitHub Desktop.
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
import Text.Regex | |
import Data.List | |
readCSV :: (String,String)->IO [[String]] | |
readCSV (fileName,delimiter) = do | |
text <- (readFile fileName) | |
let column = lines text::[String] | |
elements = map (splitRegex (mkRegex delimiter)) column | |
return elements | |
writeCSV :: (String,String) -> [[String]] ->IO () | |
writeCSV (fileName,delimiter) csv = do | |
let column = map (intercalate (delimiter)) csv | |
text = unlines column | |
writeFile fileName text |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment