Please there is this billing report i work on to update a google sheet with a daily count but now we want it hourly, when i made changes to the the function it keeps over writing on the same row until next day before it's move to the next row which means it is still using the date to move but i want it to move every hour. (for hourly counts)
see function here and assist:
=================================================
PYTHON_=/usr/local/bin/python
GSHEETS=/usr/local/bin/gsheets
sheet_name="Top_cps_billing_response_codes"
get_row_number ()
{
local start=$(date --date="$START_DATE" +%s) extra=3
local end=$(date --date="$1" +%s)
local difference=$((end-start))
QUOTIENT=$(($((difference / 86400))+extra))
return 0
}
get_row () { get_row_number "$1" && echo $QUOTIENT; }
START_DATE='2020-10-10 00' # beginning row date on the current spreadsheet
ydate=$(date --date='now -1 day' '+%Y-%m-%d')
rowval=$(get_row "$ydate")
Thank you
At the moment, your date related code is only using the date at a day level. You aren’t getting the time and looking at the hour of the day at all.
So the way it’s set up, it’s still only going to work properly if it is called once per day.
Also, I have no idea what your data looks like in your sheet. I’m not familiar with google sheets, I assume it’s just a spreadsheet like calc or the dreaded excel.
Assuming you have it set up something like this:
Code:
Date. Time
00:00 01:00 .....
2020-10-05 5 3 .....
Then I would say each time the script is ran, you need to look at the days date to find the appropriate row and then look at the hour to determine the column and then put your value in the appropriate cell.
Failing that, you’ll need to explain how your data is laid out in your sheet.
Also, you seem to have included the login credentials for your database in your post in the commented out rmcs= line.
I’ve removed that line of code from my quote above. I’d recommend removing it from your post too, otherwise anybody will be able to mess with your db!