Parse reserved words case insensitively
This commit is contained in:
parent
8df4e1ed83
commit
92f680875f
@ -105,17 +105,18 @@ parse iopts f t = do
|
|||||||
|
|
||||||
-- | Parse special separator names TAB and SPACE, or return the first
|
-- | Parse special separator names TAB and SPACE, or return the first
|
||||||
-- character. Return Nothing on empty string
|
-- character. Return Nothing on empty string
|
||||||
getSpecialSeparators :: String -> Maybe Char
|
parseSeparator :: String -> Maybe Char
|
||||||
getSpecialSeparators "SPACE" = Just ' '
|
parseSeparator = specials . map toLower
|
||||||
getSpecialSeparators "TAB" = Just '\t'
|
where specials "space" = Just ' '
|
||||||
getSpecialSeparators (x:_) = Just x
|
specials "tab" = Just '\t'
|
||||||
getSpecialSeparators [] = Nothing
|
specials (x:_) = Just x
|
||||||
|
specials [] = Nothing
|
||||||
|
|
||||||
-- | Decide which separator to get.
|
-- | Decide which separator to get.
|
||||||
-- If the external separator is provided, take it. Otherwise, look at the rules. Finally, return ','.
|
-- If the external separator is provided, take it. Otherwise, look at the rules. Finally, return ','.
|
||||||
getSeparator :: CsvRules -> Char
|
getSeparator :: CsvRules -> Char
|
||||||
getSeparator rules = head $
|
getSeparator rules = head $
|
||||||
catMaybes [ getDirective "separator" rules >>= getSpecialSeparators
|
catMaybes [ getDirective "separator" rules >>= parseSeparator
|
||||||
, Just ',']
|
, Just ',']
|
||||||
|
|
||||||
-- | Read a Journal from the given CSV data (and filename, used for error
|
-- | Read a Journal from the given CSV data (and filename, used for error
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user