pytr-org / pytr

Use TradeRepublic in terminal and mass download all documents
https://pypi.org/project/pytr/
MIT License
390 stars 71 forks source link

Customize timeformat in filenames #32

Closed marvin226 closed 3 months ago

marvin226 commented 2 years ago

Hello, thank you for your great work! pytr is a really helpful tool!

I think it would be great if we could format the datetime within the filename. My problem with the slash as time delimiter is that OneDrive cannot upload files containing a slash.

I just quickly looked into the code and thought one could parse the date and time to format it according to a user defined format, e.g. provided by another argument like --timeFormat with a default value of the existing behavior or an ISO format.

What do you think about it? If you need any support, I would be happy to help. Thank you!

marzzzello commented 2 years ago

I was wondering why your date contains slashes. Seems like the date from trade republic is different depending on your locale. I guess you use English locale. But I found a better way to get the date anyway, so I'll implement that. https://github.com/marzzzello/pytr/blob/1a798f1581ac1a7f273c60bc5eb6274ee8a97cf2/pytr/dl.py#L80-L81

marvin226 commented 2 years ago

Thanks for your quick response. I have to clarify that the time contains slashes.

Here are two example filename's located in PATH/Abrechnungen:

I wrote datetime because I thought about parsing your mentioned iso_date together with the time with datetime. But for sure one could just replace the slash with a colon too :)

marzzzello commented 2 years ago

Interesting. My files all use : instead of /

MartinScharrer commented 6 months ago

Note that with the changes in pull request https://github.com/marzzzello/pytr/pull/55 the local file name is stored as part of the event JSON. It would be possible to write another python script which then goes through them and renames the files as the user pleases. I am planning to generate some import data for Portfolio Performance from it.