Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

read csv without header #84

Open
jpduyx opened this issue Oct 8, 2023 · 3 comments
Open

read csv without header #84

jpduyx opened this issue Oct 8, 2023 · 3 comments

Comments

@jpduyx
Copy link

jpduyx commented Oct 8, 2023

Is there somewhere an option to define column names for csv files that don't have a header?

@redstreet
Copy link
Owner

redstreet commented Oct 8, 2023

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.

@jpduyx
Copy link
Author

jpduyx commented Oct 8, 2023

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 ...

@redstreet
Copy link
Owner

redstreet commented Oct 8, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants