Commit 113cd751 authored by pm3g19's avatar pm3g19
Browse files

Added module for reading in CSV file

parent 33c138b6
module ReadCSV where
import System.IO
readCSV :: FilePath -> IO [[String]]
readCSV fname = do
str <- readFile fname
return $ readCSVString str
readCSVString :: String -> [[String]]
readCSVString whole = [splitElem ',' line | line <- splitElem '\n' whole]
splitElem :: Eq a => a -> [a] -> [[a]]
splitElem elem = split (/=elem)
split :: (a -> Bool) -> [a] -> [[a]]
split p l = case span p l of
([], _) -> []
(match, []) -> [match]
(match, _:rem') -> match:split p rem'
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment