Skip to content

Commit cb7b6c9

Browse files
authored
fix: strip UTF8 BOM when reading CSV file (#139)
Fixes #138
1 parent 790fa81 commit cb7b6c9

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/DataFrame/IO/CSV.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,8 @@ ghci> D.readSeparated (D.defaultReadOptions { columnSeparator = ';' }) ".\/data\
236236
readSeparated :: ReadOptions -> FilePath -> IO DataFrame
237237
readSeparated !opts !path = do
238238
let sep = columnSeparator opts
239-
csvData <- BL.readFile path
239+
let stripUtf8Bom bs = fromMaybe bs (BL.stripPrefix "\xEF\xBB\xBF" bs)
240+
csvData <- stripUtf8Bom <$> BL.readFile path
240241
let decodeOpts = Csv.defaultDecodeOptions{Csv.decDelimiter = fromIntegral (ord sep)}
241242
let stream = CsvStream.decodeWith decodeOpts Csv.NoHeader csvData
242243

0 commit comments

Comments
 (0)