From d2b318506255ffd1676dd0bb5fcf80ed4b8edc92 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Fri, 14 Jun 2019 16:17:40 -0700 Subject: [PATCH] csv: don't show invalid inter-field spaces in CSV error messages Errors involving a record like: 2000-01-01,a,"1" displayed the record with extra spaces: the CSV record is: "2000-01-01", "a", "1" which was not accurate or valid RFC-4180. --- hledger-lib/Hledger/Read/CsvReader.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hledger-lib/Hledger/Read/CsvReader.hs b/hledger-lib/Hledger/Read/CsvReader.hs index 09668bf03..5875f7a4e 100644 --- a/hledger-lib/Hledger/Read/CsvReader.hs +++ b/hledger-lib/Hledger/Read/CsvReader.hs @@ -675,7 +675,7 @@ transactionFromCsvRecord sourcepos rules record = t mdate2' = maybe Nothing (maybe (error' $ dateerror "date2" (fromMaybe "" mdate2) mdateformat) Just . mparsedate) mdate2 dateerror datefield value mdateformat = unlines ["error: could not parse \""++value++"\" as a date using date format "++maybe "\"YYYY/M/D\", \"YYYY-M-D\" or \"YYYY.M.D\"" show mdateformat - ,"the CSV record is: "++intercalate ", " (map show record) + ,"the CSV record is: "++showRecord record ,"the "++datefield++" rule is: "++(fromMaybe "required, but missing" $ mfieldtemplate datefield) ,"the date-format is: "++fromMaybe "unspecified" mdateformat ,"you may need to " @@ -822,7 +822,7 @@ negateStr s = '-':s -- | Show a (approximate) recreation of the original CSV record. showRecord :: CsvRecord -> String -showRecord r = "the CSV record is: "++intercalate ", " (map show r) +showRecord r = "the CSV record is: "++intercalate "," (map show r) -- | Given the conversion rules, a CSV record and a journal entry field name, find -- the template value ultimately assigned to this field, either at top