diff options
author | Jed Barber <jjbarber@y7mail.com> | 2017-01-31 14:54:02 +1100 |
---|---|---|
committer | Jed Barber <jjbarber@y7mail.com> | 2017-01-31 14:54:02 +1100 |
commit | ca7337e57786a0db79865d63e797b574942795e0 (patch) | |
tree | 7f46e4ae14eb8816c195bd09cb9076a25a074c5e /src/CSV.hs | |
parent | 0e233d7687bf121c48727cf4ff06767b4ab04d4c (diff) |
Improved CSV unparsing and more checks on doCount input
Diffstat (limited to 'src/CSV.hs')
-rw-r--r-- | src/CSV.hs | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -55,7 +55,10 @@ specialChars s = (separator s):(quote s):(escape s):[] unParseRecord :: Settings -> [String] -> String unParseRecord settings record = let escFunc c = if (c == escape settings || c == quote settings) then (escape settings):c:[] else c:[] - escapeField s = ((quote settings) : (concatMap escFunc s)) ++ ((quote settings):[]) + escapeField s = + if ((escape settings) `elem` s || (quote settings) `elem` s || (separator settings) `elem` s) + then ((quote settings) : (concatMap escFunc s)) ++ ((quote settings):[]) + else s in List.intercalate [separator settings] (map escapeField record) |