(OLD) (ARCHIVED) Puppy Linux Discussion Forum Forum Index (OLD) (ARCHIVED) Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info

This forum can also be accessed as http://oldforum.puppylinux.com
It is now read-only and serves only as archives.

Please register over the NEW forum
https://forum.puppylinux.com
and continue your work there. Thank you.

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups    
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Tue 09 Mar 2021, 06:08
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
How to create a cleaning roster with Bash?
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies. View previous topic :: View next topic
Page 1 of 1 [10 Posts]  
Author Message
bpuppy


Joined: 25 Apr 2017
Posts: 14
Location: Quebec

PostPosted: Mon 24 Dec 2018, 08:18    Post subject:  How to create a cleaning roster with Bash?
Subject description: coded with bash and date %V
 

I have to create a cleaning roster for an appartment building and would like to automate it with GNU bash if possible.

Requirements:
The tenants have to clean the corridor on their floor every week.
The cycle starts on Feb. 11, 2019 and lasts for 30 weeks (10x3).
There are 4 floors to my building.
There are 10 tenants capable of doing the task per floor.
The names of the tenants are in the 3rd column of the file tenants.csv, (sep=|).
The 1st column contains the appartment number which if it starts with a 2, such as in 214 means they are located on Floor number 2.

I'd like to generate the dates automatically (maybe from the Date command week number %V which is starting on mondays) and merge in the names of the tenants from the csv file. Use of the date command and %V is way more complicated than I am used to. I don't know how to tackle this. Question

Desired Output (sample taken from the 2018 roster):
snap-019.jpg
 Description   
 Filesize   8.69 KB
 Viewed   290 Time(s)

snap-019.jpg

Back to top
View user's profile Send private message 
fabrice_035


Joined: 28 Apr 2014
Posts: 768
Location: Bretagne / France

PostPosted: Mon 24 Dec 2018, 11:16    Post subject:  

Hey,

My idea, use https://www.google.com/sheets/about/ https://www.google.com/sheets/about/

And search a forum to talk about if you a newbie Wink

Regard

_________________
Bionicpup64-8.0 _ Kernel 5.4.27-64oz _ Asus Rog GL752
Back to top
View user's profile Send private message 
some1

Joined: 17 Jan 2013
Posts: 123

PostPosted: Mon 24 Dec 2018, 14:23    Post subject:  

You explained the problem very well.

I noticed that:
1) You operate with 10 workers.
2) Apartment-number can be 214.

Q: Can you have more tenants per floor -
than those enrolled to work?
If so - we need a creteria/filter to extract
the doers from the tenants.csv-file.
---
Its a busy evening around here - so I have to leave -
but will be back with the date-solution(s).
Could you sketch how you intend to code the solution -
my hunch is that you are acquainted with arrays/is a coder.

Anyway - Merry Christmas.
Back to top
View user's profile Send private message 
bpuppy


Joined: 25 Apr 2017
Posts: 14
Location: Quebec

PostPosted: Tue 25 Dec 2018, 22:04    Post subject:  

Hi some1 and fabrice,

Quote:
Q: Can you have more tenants per floor -
than those enrolled to work?
If so - we need a creteria/filter to extract
the doers from the tenants.csv-file.


Yes, we do have more tenants but they are not capable of doing the job due to old age or handicaps. But i have a csv list of names of only those capable as they change very little from 1 cycle to the other.

So the merging of names to the dates and floors will be a matter of using awk properly.

What really bugs me, is how do i translate the date command %V (because the week starts on Mondays) as such:

`date +%V` gives the week number but i need it to give me the reverse to determine the 3 dates for Mrs.X, as they must be week 06, week 16 and week 26, so that week 16 = Apr 15 and that week 26 = Jun 24. Thus, my first line would be:

Feb 11, Apr 15, Jun 24 Mrs.X Mr.Y Ms.XX Mr.YY

I could start coding using vars such as [date_01..date_30] and replace them later by their real values if we figure out how to get those dates. Maybe, it's impossible with the 'date' command... i wonder.

Anyhow, like you say, these are busy days for all and i have at least 6-8 weeks before the roster is needed (though i will do it manually if no solution comes to mind.)
It's just a challenge i wanted to do for the fun of it. I love using bash and yad, i always want to know more!

Thanks for your reply and Merry Christmas to both of you Very Happy
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 2084
Location: Japan

PostPosted: Wed 26 Dec 2018, 01:59    Post subject:  

bpuppy wrote:
they must be week 06, week 16 and week 26, so that week 16 = Apr 15 and that week 26 = Jun 24. Thus, my first line would be:

Feb 11, Apr 15, Jun 24 Mrs.X Mr.Y Ms.XX Mr.YY
Shouldn't your cycle start on Feb 4 2019?
I think you mixed up the years:
Code:
# date -d "2/11/2018" +%V
06
# date -d "2/11/2019" +%V
07
# date -d "2/4/2019" +%V
06

I also wonder why you insist on using the %V option. You know the start day of the cycle and you know that a week has 7 days. What would you need the ISO week number for?
Back to top
View user's profile Send private message 
6502coder


Joined: 23 Mar 2009
Posts: 682
Location: Western United States

PostPosted: Wed 26 Dec 2018, 02:10    Post subject:  

Here's a quick-and-dirty attempt at a solution.
Just bash, the date command, and some awk.

Edit: I see I forgot to rename "doit.sh" to the intended name "hallduty.sh"; too much eggnog! ("doit.sh" is my generic name for nonce scripts). Fixed now.
hallduty.zip
Description  Unzip anywhere convenient. Read the Readme.txt
zip

 Download 
Filename  hallduty.zip 
Filesize  2.16 KB 
Downloaded  160 Time(s) 
Back to top
View user's profile Send private message 
bpuppy


Joined: 25 Apr 2017
Posts: 14
Location: Quebec

PostPosted: Wed 26 Dec 2018, 07:33    Post subject:  

@MochiMoppel

Thanks for pointing that out.

After checking back on the 2019 calendar year, i can see why i said week 6. %V is said to start weeks on Mondays. If you check on January 2019, we find that the 1st falls on a Tuesday, thus making Feb. 11, 2019 equal to week 6 while in reality it is week 7.

I will make the adjustment.
Cordially
Back to top
View user's profile Send private message 
bpuppy


Joined: 25 Apr 2017
Posts: 14
Location: Quebec

PostPosted: Wed 26 Dec 2018, 14:21    Post subject: hallduty script
Subject description: works flawlessly
 

@6502coder,

Super Awsome. Exactly what i was looking for. BTW, you are an excellent problem solver. I'll take the week in my spare time to analyze it thouroughly Very Happy

Once i get it all, i'll make some kind of template to merge the info to some final presentation format. With the dates all figured out, i should not have much trouble with that.

Cheers!
Back to top
View user's profile Send private message 
6502coder


Joined: 23 Mar 2009
Posts: 682
Location: Western United States

PostPosted: Wed 26 Dec 2018, 18:13    Post subject:  

Thanks, glad to help. I enjoy taking on a problem as I almost always learn something in the process, even if I'm unsuccessful.

BTW the caveat implying that the script doesn't work across a year-end boundary can be ignored. It's a left-over from an early version of the script. The present version should handle such cases; e.g. changing the "week" parameter in the function "makeDates" from 7 to 41 gives a schedule that starts Oct 7, 2019 and extends well into 2020.
Back to top
View user's profile Send private message 
mikeslr


Joined: 16 Jun 2008
Posts: 3913
Location: 500 seconds from Sol

PostPosted: Wed 26 Dec 2018, 20:11    Post subject:  

Misread your post's title. ('Embarassed')
Thought this problem had been solved long ago. ('Shocked')

Suggest the assignment sheets advise that those assigned can trade dates for doing the cleaning with others, but that the person assigned will be responsible for the cleaning on the date assigned. The ability of the tenants to exchange their actual cleaning date makes an assignment less arbitrary. Spelling out the significance of a trade saves you from having to do the juggling when something occurs (illness, vacation...) or mediating disputes as to who was responsible for the work not being done when there was a trade.
hen-on-egg.jpg
 Description   Step 3 in creating rooster
 Filesize   66.48 KB
 Viewed   117 Time(s)

hen-on-egg.jpg

Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [10 Posts]  
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies. View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1092s ][ Queries: 12 (0.0382s) ][ GZIP on ]