Argh, don’t have my laptop now, so this is hard, but with the init 
function, the right hand fields in the dictionary are internal, and fixed. 
The left hand side corresponds to your csv file.

Date,Description,Amount,Unapplied,Balance
def custom_init(self): self.max_rounding_error = 0.04 
self.filename_pattern_def = '<change_this>.*' self.header_identifier = 
'Date,Description,Amount,Unapplied,Balance', self.date_format = '%m/%d/%Y' # 
<--- this is incorrect, change this self.header_map = { "Description": 
'payee', "Date": 'date', "Amount": 'amount', "Balance": 'balance', } 

I can’t remember of the top of my head if you need a get_balance_statement() 
function to generate the balance assertion. If you do, it’ll look like this 
<https://github.com/redstreet/beancount_reds_importers/blob/47afef6b4e8b0de6a0aef403bdfa993f9de8dcd5/beancount_reds_importers/importers/schwab/schwab_csv_checking.py#L49-L54>
.

This is all untested. If that doesn’t work, let me know.
​


On Friday, December 8, 2023 at 12:19:53 AM UTC-8 Red S wrote:

> 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/b483cfbd-bfe3-4438-b147-c2b93dfebe81n%40googlegroups.com.

Reply via email to