Hello there, Author here. Given how simple your csv file is, I’d suggest using Beancount’s built in csv importer <https://beancount.github.io/docs/api_reference/beancount.ingest.html#beancount.ingest.importers.csv>. Something like this in your my.import file (untested): csv.Importer({Col.DATE: 'Date', Col.NARRATION1: 'Description', Col.AMOUNT: 'Amount', }, 'Assets:Bank1', 'USD', ('Date','Description','Amount', 'Unapplied','Balance')),
The only advantage you get with my reds-importers is balance assertions. I'll post and example in a minute. On Thursday, December 7, 2023 at 7:06:19 PM UTC-8 micro...@gmail.com wrote: > I have what I think may be a very simple CSV file: > > Column headers are these: > Date,Description,Amount,Unapplied,Balance > > Corresponding data fields look like this: > Dec 1, 2023,PAYMENT,$951.28,$951.28,$25,000.62 > > I have had some success using Red's ofx importer framework, but am really > struggling to figure out the CSV importer from the examples in the git > repo. I started with the Discover example that looks like this: > > from beancount_reds_importers.libreader import csvreader > from beancount_reds_importers.libtransactionbuilder import banking > > class Importer(csvreader.Importer, banking.Importer): > IMPORTER_NAME = """ Discover credit card .csv importer.""" > > def custom_init(self): > self.max_rounding_error = 0.04 > self.filename_pattern_def = 'Discover.*' > self.header_identifier = 'Trans. Date,Post > Date,Description,Amount,Category' > self.date_format = '%m/%d/%Y' > self.header_map = { > "Category": 'payee', > "Description": 'memo', > "Trans. Date": 'date', > "Post Date": 'postDate', > "Amount": 'amount', > } > > def skip_transaction(self, ot): > return False > > def prepare_processed_table(self, rdr): > # Need to invert numbers supplied by Discover > rdr = rdr.convert('amount', lambda x: -1 * x) > return rdr > > I'm pretty sure I don't need the def skip_transaction(self, ot) and def > prepare_processed_table(self, rdr): bits, but am at a loss to figure out > what fields I need to modify in the def custom_init(self) for my situation. > There is not an example CSV file for that importer in the repo so it makes > it a little more challenging for me to hack on it. I think I don't need the > "Unapplied" column but am not sure. Even just some hints would be really > helpful. > > Thank you in advance! > Chris > -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/beancount/3a0039f7-8d93-4e38-ab6b-416c2316cb09n%40googlegroups.com.