Thanks guys, that helps a ton! On Tuesday, October 17, 2017 at 9:58:51 AM UTC+2, Zhuoyun Wei wrote: > > > 2017-10-16 23:01:36 Martin Blais <[email protected] <javascript:>>: > > > > In order to do that, I would suggest going LO-FI and using sed (or > Python), and working off of the input text directly. > > Working off of the parsed input will just cause you headaches. > > > > I had a few similar use cases with Holger -- renaming a account while > preserving the indentation and whitespace, reformat the payee + > narration field, etc. > > I found the fileinput module from Python stdlib extremely useful in > these cases: > > > with fileinput.input('ledger.bean', inplace=True) as f: > for line in f: > new_line = process_line(line) > print(new_line, end='') > > > With inplace=True parameter, it's like `sed -i`, but with all the > powerful batteries of Python. > > > -- > Zhuoyun Wei >
-- 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 [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/beancount/0c05e918-2d55-467a-9206-219819bbe55a%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
