dresdner353 / energyutils

Collection of utility scripts for energy monitoring
17 stars 5 forks source link

gen_report.py #2

Open pjmm1 opened 8 months ago

pjmm1 commented 8 months ago

Hi I would like to remove some of the columns in the spreadsheet can I do this using a filter if so can you give me an example Regards

dresdner353 commented 8 months ago

can you highlight any specific fields you are trying to remove?

The entire data aggregation processing is a pretty involved to convert data from hours to days, weeks, months etc and a lot of those fields are required to make things work in terms of that aggregation.

That said, to provide a means of removing fields, I'd have to look into adding a filter option of sorts where you invoke the report generator and give it a list of fields you do not want in the resulting sheets. That would have knock-on effect on the graphs also, causing some to vanish if the related fields are not present in the sheet data.

The Excel format has a concept of hiding columns and its likely I can leverage that in the generation.

pjmm1 commented 8 months ago

Several of the fields like dates and times are duplicates. Would it be possible to list the Colom's you do not want to display would that be easier. see attached Capture

pjmm1 commented 8 months ago

If it was also possable to change the width of the calms this would save space

dresdner353 commented 8 months ago

Those date/time fields are there instead for data pivots. You can use them to apply filters and show all data for selected years, months or weeks by using those fields as filter references. It allows for fast filtering of data when you're trying to reduce the data set.

I will look into adding an option to list columns for hiding. This should result in the desired columns being hidden when the file is opened. You can still use the menus to show the hidden columns after the fact.

I'll play around with it later tonight and ping back to this post if I manage to get something working.

dresdner353 commented 8 months ago

This turned out to be a pretty easy tweak. So do a git pull to update the code or re-download the zip file.

In the batch file to generate the report, you can now add a new option --hide_columns with a space separated list of fields to hide. The names used in this list are the lowercase internal keys for the fields and not necessarily the same as the title names shown.

Example here.. hiding year, month and week fields..

%PYTHON% %GEN_REPORT_SCRIPT% ^ --idir %SHELLY_DATA% ^ --file shelly_report_ev.xlsx ^ --reports %REPORTS% ^ --hide_columns year month week ^ --tariff_rate Day:0.4320 Night:0.2086 Boost:0.1225 ^ --tariff_interval 08-23:Day 23-08:Night 02-04:Boost ^ --annual_standing_charge 303 ^ --fit_rate 0.21

The full list can be determined by running the script with the --help option or checking the usage document at.. https://github.com/dresdner353/energyutils/blob/main/GEN_REPORT.md

That full list of field codes is.. datetime ts year month week day weekday hour hours tariff_name tariff_rate standing_rate standing_cost import import_cost solar battery_solar_charge battery_grid_charge battery_charge battery_discharge battery_storage battery_capacity solar_consumed solar_consumed_percent solar_credit export_rate export export_percent export_credit consumed rel_import savings savings_percent bill_amount

pjmm1 commented 8 months ago

Many Thanks I will have a look at this tomorrow and let you know how I get on Regards