simonmichael / hledger

Robust, fast, intuitive plain text accounting tool with CLI, TUI and web interfaces.
https://hledger.org
GNU General Public License v3.0
2.85k stars 307 forks source link

imp: Support tsv and ssv prefixes (#2164) #2165

Closed reesmichael1 closed 4 months ago

reesmichael1 commented 4 months ago

With these changes, hledger now supports using the ssv: and tsv: prefixes to determine the file separator. For example:

$ cat basic_s
Date;Description;Id;Amount
12/11/2019;Foo;123;10.23
$ cat basic_s.rules
skip         1
fields       date, description, , amount
date-format  %d/%m/%Y
$ hledger print -f ssv:basic_s # stock hledger cannot parse the file
The hledger journal file "/home/michael/builds/hledger/ssv:basic_s" was not found.
Please create it first, eg with "hledger add" or a text editor.
Or, specify an existing journal file with -f or LEDGER_FILE.
$ stack exec -- hledger print -f ssv:basic_s # But this new build can!
2019-11-12 Foo
    expenses:unknown           10.23
    income:unknown            -10.23

Some notes from my end:

simonmichael commented 4 months ago

Great, thank you!

I had a few thoughts but they're not too important; I'm inclined to merge this and maybe (or not) do a followup PR or tweaks at some point.

simonmichael commented 4 months ago

Our csv reader is really a Character Separated Values reader, it can handle any separator character. I guess these changes don't disrupt with that; for other characters the .csv extension or csv: prefix should be used, as before.

simonmichael commented 4 months ago

Clarified https://hledger.org/dev/hledger.html#data-formats a little.

reesmichael1 commented 4 months ago

Cool, thanks! I was also thinking about clarifying those docs in the shower this morning, but looks like you beat me to it :grinning: