--
You received this message because you are subscribed to the Google Groups "Beancount" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beancount+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beancount/4b6c37cd-dab7-4683-80fc-e6affac7e1ca%40googlegroups.com.
You will want to write a little python script.I would operate on source code, not on the data structures, so you keep the original formatting and metadata and comments
On Fri, Dec 20, 2019, 06:59 nug get <nugget....@gmail.com> wrote:
--Is there a feature that would allow me to sort the transactions in my files, for example by date, or specific accounts?Thanks!Background:
I migrated my 3 years of Gnucash records to beancount. It's all one long list of transactions sorted by date. I'd like to separate my cash and bank account transactions into two different files.
You received this message because you are subscribed to the Google Groups "Beancount" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bean...@googlegroups.com.
#!/usr/bin/python3
import sys
matchers = sys.argv[4:]
infile = open(sys.argv[1], "r")
chunk = None
lastone = None
def match(text):
return all (m in text for m in matchers)
def start_condition(line):
return line.startswith("20") or line.startswith(";")
def end_condition(line):
return not bool(line.rstrip("\n"))
with open(sys.argv[2], "w") as matched:
with open(sys.argv[3], "w") as notmatched:
for line in infile:
if chunk is not None:
chunk += line
if end_condition(line):
# Chunk over. We print.
lastone = (matched if match(chunk) else notmatched)
lastone.write(chunk)
chunk = None
else:
if start_condition(line):
chunk = line
else:
matched.write(line)
notmatched.write(line)
if chunk is not None:
(matched if match(chunk) else notmatched).write(chunk)
To unsubscribe from this group and stop receiving emails from it, send an email to beancount+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beancount/a728b410-6f4d-4623-b7fb-e40d03eb0cf8%40googlegroups.com.
--
Rudd-O
http://rudd-o.com/
--
You received this message because you are subscribed to the Google Groups "Beancount" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beancount+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beancount/4b6c37cd-dab7-4683-80fc-e6affac7e1ca%40googlegroups.com.
--
Rudd-O
http://rudd-o.com/
To view this discussion on the web visit https://groups.google.com/d/msgid/beancount/d117b6cb-67e1-3e59-1c39-928cee0672a7%40rudd-o.com.
Hmm. It would be nice if the metadata produced by the parser contained both the starting and end line.This way you wouldn't have to do any parsing to extract the original text.
I'll put that on the list for v3 changes.
Thanks!
--
Rudd-O
http://rudd-o.com/
To unsubscribe from this group and stop receiving emails from it, send an email to beancount+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beancount/4396ceeb-4d8c-49d1-9ccb-1acc4927c896n%40googlegroups.com.