hledger
hledger copied to clipboard
csv rules file parse errors should be clearer
An import command was failing with:
hledger: user error (could not parse date "")
It wasn't the destination journal file, the source csv file, or any of the rules files, but an extra newline in the .latest.FOO.csv
file. Hard to discover.
The same confusing error arises when a newbie (like me) forgets to skip the csv header line. Code does not notice that is trying to parse "Transaction Date" as a date. It would be nice if a suggestion was offered to add the skip. I kept on trying to find the right date format to use instead of realizing "duh, you forgot to skip!!" :)
The same confusing error arises when a newbie (like me) forgets to skip the csv header line. Code does not notice that is trying to parse "Transaction Date" as a date. It would be nice if a suggestion was offered to add the skip. I kept on trying to find the right date format to use instead of realizing "duh, you forgot to skip!!" :)
+1
In my case the 1st column of the CSV is "Date", and so the error I was getting is:
hledger: error: could not parse "Date" as a date using date format "YYYY/M/D", "YYYY-M-D" or "YYYY.M.D"
I took this error as if the tool was properly reading the "Date" but somehow not understanding the format
If the first column of the CSV had been something different the error would have been obvious though...
Thanks for the reports. I have opened #1863 to track that issue .
For this problem (empty lines in .latest.import.csv
) I think we can safely filter out these empty lines. Seems like a very local patch, and I do not see an obvious drawbacks. Am I missing something?
Yes that would be good too.