hledger icon indicating copy to clipboard operation
hledger copied to clipboard

csv rules file parse errors should be clearer

Open simonmichael opened this issue 2 years ago • 5 comments

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.

simonmichael avatar Mar 02 '22 02:03 simonmichael

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!!" :)

tvc-amaffei avatar Mar 24 '22 12:03 tvc-amaffei

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...

kiteloopdesign avatar Apr 26 '22 14:04 kiteloopdesign

Thanks for the reports. I have opened #1863 to track that issue .

simonmichael avatar Apr 26 '22 20:04 simonmichael

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?

ShrykeWindgrace avatar Dec 01 '23 08:12 ShrykeWindgrace

Yes that would be good too.

simonmichael avatar Dec 01 '23 17:12 simonmichael