read csv without header
Opened this issue · 3 comments
Is there somewhere an option to define column names for csv files that don't have a header?
Good question, there isn't currently. PR welcome.
A couple lines of code are needed to ensure petl
(underlying library that csv uses) gets the header from the importer configuration instead of from the .csv file.
Thanks @redstreet for the reply ..
during my search trough the examples and code I also found "prepare_table()" and adding 2 lines in there seams to do the trick without altering any other internals
def prepare_table(self, rdr):
rdr = etl.setheader(rdr, ['Date', 'Payee', ['etc'])
return rdr
Now I'm reading again in the bank documentation and try to understand all the fields to figure out which I can use. And probably some of the fields can combined to be used in the transaction description and that would also be done in the prepare_table() i guess ...
Cool, that's a good place for that header line! Even better would be in prepare_raw-file().
Yes, prepare_table is meant exactly for the types of operations you described. Search for that across the repo to view examples that should do what you're trying to do.
BTW, this is probably what you are already doing but you can simply define those two methods in your own importer. They're meant to be overridden that way.