Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/DataFrame/IO/CSV.hs
Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,14 @@ ghci> D.readSeparated (D.defaultReadOptions { columnSeparator = ';' }) ".\/data\
@
-}
readSeparated :: ReadOptions -> FilePath -> IO DataFrame
readSeparated !opts !path = do
let sep = columnSeparator opts
readSeparated opts !path = do
let stripUtf8Bom bs = fromMaybe bs (BL.stripPrefix "\xEF\xBB\xBF" bs)
csvData <- stripUtf8Bom <$> BL.readFile path
decodeSeparated opts csvData

decodeSeparated :: ReadOptions -> BL.ByteString -> IO DataFrame
decodeSeparated !opts csvData = do
let sep = columnSeparator opts
let decodeOpts = Csv.defaultDecodeOptions{Csv.decDelimiter = fromIntegral (ord sep)}
let stream = CsvStream.decodeWith decodeOpts Csv.NoHeader csvData

Expand Down