Processing Google Calendar Data

1,590 views
Skip to first unread message

Mike

unread,
Aug 9, 2012, 11:30:46 PM8/9/12
to tas...@googlegroups.com
I have seen many instances of downloading the calendar data to a text file and parsing it from there so I'm not totally lost, however I don't understand how the data is being parsed and looking at the data from several tasks I've downloaded doesn't help much. What I want to do is look at my calendar entries each morning and then process tasks by the days events. I only need it to run once each day but I want it to handle all of the days events. My task can loop and handle each entry one at a time as far as I'm concerned. I see the calendar entry state but I don't think this will be very helpful in this. If I'm wrong, please educate me on the use of the calendar entry state. New to Tasker but I'm learning, even if so far it's mostly by tearing apart something that someone else has done and reverse engineering it. Thanks ahead of time for any help I get...

Jakub

unread,
Aug 10, 2012, 5:51:10 AM8/10/12
to tas...@googlegroups.com

easiuser

unread,
Aug 10, 2012, 10:28:13 AM8/10/12
to tas...@googlegroups.com
After your post, I started to do the same thing.  Not a high priority for me but this will get you in the right direction.  From my HTTP get, every appointment begins with "When:"  followed by the data, then "When:" followed by the data and finally "Description:" followed by the data.  You will have to make adjustments to pull out the exact info you need but assuming you saved your data to testhttp.txt, the following actions will pull out the when and where of the next appointment and put it in %DayAppt211 and %DayAppt212 respectively.  You can repeat A3 and A4 with %DayAppt3, %DayAppt4, etc for the subsequent appointments.
 
There are still a few trailing formatting characters but as I said, you will need to do more parsing to get at the info you need.
 
 
A1: Read File [ File:testhttp.txt To Var:%DayAppt ]
A2: Variable Split [ Name:%DayAppt Splitter:When: Delete Base:Off ]
A3: Variable Split [ Name:%DayAppt2 Splitter:Event Delete Base:Off ]
A4: Variable Split [ Name:%DayAppt21 Splitter:Where: Delete Base:Off ]

On Thursday, August 9, 2012 10:30:46 PM UTC-5, Mike wrote:

Mike Maynard

unread,
Aug 10, 2012, 1:55:10 PM8/10/12
to tas...@googlegroups.com
That link is totally useless for me :=(  does it do anything of value to anyone else?  (I presume this is part of the 'new google groups' discussion)

easiuser

unread,
Aug 10, 2012, 2:21:19 PM8/10/12
to tas...@googlegroups.com, mmay...@rochester.rr.com
It is just a link to search this group using "google calendar" as keywords.

Mike Maynard

unread,
Aug 10, 2012, 2:29:28 PM8/10/12
to tas...@googlegroups.com
Oh, I was hoping something specific was being pointed out :-)

Michael Yeager

unread,
Aug 10, 2012, 5:33:30 PM8/10/12
to tas...@googlegroups.com

I’m going to plug your routine in and see if it gets me what I’m looking for. It might help me understand how the data gets handled a little bit. That is where I’m really lost at the moment. Once I know how to get the data I want, then I can start working on how to handle and process it. Programming Tasker seems a lot like programming in basic with a bunch of built in routines that you don’t have to write. I’m rusty as hell on programming but I’ll figure it out sooner or later. Leaning real hard on other people’s stuff to learn how some of this works…

Michael Yeager

unread,
Aug 11, 2012, 3:57:57 PM8/11/12
to tas...@googlegroups.com

I'm gutting another task I got from pocketables but it's not processing the variables correctly after the first or second task. Understanding a bit better how variable split functions but stumped by the appearance that it won't function reliably. Will post what I have later so you can see if you can figure out if I did something wrong.

Mike

unread,
Aug 11, 2012, 9:58:21 PM8/11/12
to tas...@googlegroups.com

Ok, here's where I'm at. I am reading the calendar into a file and them using READ FILE to read the data into the variable %Calendar. Below is the steps I'm using from there...

Variable Split %Calendar / <title type='text'>
Variable Split %Calendar3 / </title>
Variable Split %Calendar32 / <content type='text'>
Variable Split %Calendar322 / </content>

The result of this leaves me with %Calendar31 being the event title all cleaned up and ready to go and %Calendar3221 holding the comment for the event if there is one. The problem that I have is that if I try to do this for %Calendar4 and %Calendar5 (or beyond), starting at %Calendar4 the split fails to clean up the event name. If I split %Calendar3,4,5,6,7,8,9 and then go back and do the 32,322,42,422 etc then it works fine. Don't know why but I guess it really doesn't matter. Is it possible to do this in a loop to reduce the size of the task? It would be great to process %Calendar(x) with x being incremented the appropriate number of times. Something tells me this would have to be done in an array and I have no idea how Tasker handles arrays. Not sure if I'm ready to try to figure that out yet...

Mike Maynard

unread,
Aug 11, 2012, 10:35:42 PM8/11/12
to tas...@googlegroups.com
Mike, do you have a copy of the XML output that you are using in the file?  I think that will help explain the issue.

What I have been looking at doing, would be to start splitting at the <entry> tag, as every event starts with this tag.  Then proceeding through a loop that breaks apart the data for the event, and places it all in an array.  Repeating this loop until it doesnt find the <entry> tag anymore.

What I dont know, is if this will work for sure.  I dont really understand the Variable Split command perfectly just yet....

Can anyone help on this?  An entry in my calendar looks like follows:

- <entry>
<published>2012-07-25T23:13:07.000Z</published>
<updated>2012-08-01T18:11:23.000Z</updated>
<title type="text">TITLE- More Title</title>
<content type="text" />
<link rel="alternate" type="text/html" href="http://www.google.com/calendar/event?eid=xxxxxx" title="alternate" />
<link rel="self" type="application/atom+xml" href="http://www.google.com/calendar/feeds/mike%40xxxx.com/private-xxxxxx" />
- <author>
<name>Mike Maynard</name>
<email>mi...@xxxx.com</email>
</author>
<gd:where valueString="" />
<gd:when endTime="2012-08-09T10:00:00.000-04:00" startTime="2012-08-09T07:00:00.000-04:00" />
<gd:transparency value="http://schemas.google.com/g/2005#event.opaque" />
<gCal:anyoneCanAddSelf value="false" />
<gCal:guestsCanInviteOthers value="true" />
<gCal:guestsCanModify value="false" />
<gCal:guestsCanSeeGuests value="true" />
<gCal:sequence value="0" />
<gCal:uid value="ssss@google.com" />
</entry>

I think seeing an example based off my real data will help me tremendously.  The 2 fields I am really looking for are the Event Title, and gd:where valueString


Thanks
Mike
Message has been deleted

easiuser

unread,
Aug 12, 2012, 1:59:19 AM8/12/12
to tas...@googlegroups.com
Mike,  You prompted me to parse my own data.  When ran, your event data should be in their respective array variables.  I don't know how many events Tasker can handle, but I hope it works for you.

Agenda (117)
    A1: HTTP Get [ Server:Port:https://www.google.com/calendar/feeds/xxx%40gmail.com/private-xxx/full?start-min=2012-08-11T00:00:00&start-max=2012-08-11T23:59:59 Path: Attributes: Cookies: Timeout:67 Mime Type: Output File:agenda.txt ]
    A2: Read File [ File:agenda.txt To Var:%myAppt ]
    A3: Variable Split [ Name:%myAppt Splitter:<openSearch:totalResults> Delete Base:Off ]
    A4: Variable Split [ Name:%myAppt2 Splitter:</openSearch:totalResults> Delete Base:Off ]
    <%cntEvents is the number of events returned>
    A5: Variable Set [ Name:%cntEvents To:%myAppt21 Do Maths:Off Append:Off ]
    A6: Variable Set [ Name:%Event To:%myAppt22 Do Maths:Off Append:Off ]
    <Splits file into %Events2,3,4,...>
    A7: Variable Split [ Name:%Event Splitter:#kind Delete Base:Off ]
    A8: Variable Set [ Name:%last To:%cntEvents+1 Do Maths:On Append:Off ]
    <For each event found>
    A9: For [ Variable:%item Items:%Event(2:%last) ]
    A10: Variable Split [ Name:%item Splitter:event'/><title type='text'> Delete Base:Off ]
    A11: Variable Split [ Name:%item2 Splitter:</title> Delete Base:Off ]
    <Push the Event Title>
    A12: Array Push [ Name:%EventTitle Position:1 Value:%item21 Fill Spaces:Off ]
    A13: Variable Split [ Name:%item Splitter:><content type='text'> Delete Base:Off ]
    A14: Variable Split [ Name:%item2 Splitter:</content> Delete Base:Off ]
    <Push the Event Content>
    A15: Array Push [ Name:%EventContent Position:1 Value:%item21 Fill Spaces:Off ]
    A16: Variable Split [ Name:%item Splitter:<gd:where valueString=' Delete Base:Off ]
    A17: Variable Split [ Name:%item2 Splitter:'/> Delete Base:Off ]
    <Push the Event Location>
    A18: Array Push [ Name:%EventWhere Position:1 Value:%item21 Fill Spaces:Off ]
    A19: Variable Split [ Name:%item Splitter:endTime=' Delete Base:Off ]
    A20: Variable Split [ Name:%item2 Splitter:' Delete Base:Off ]
    <Push the Event End Time>
    A21: Array Push [ Name:%EventEnd Position:1 Value:%item21 Fill Spaces:Off ]
    A22: Variable Split [ Name:%item Splitter:' startTime=' Delete Base:Off ]
    A23: Variable Split [ Name:%item2 Splitter:> Delete Base:Off ]
    <Push the Event Start Time>
    A24: Array Push [ Name:%EventStart Position:1 Value:%item21 Fill Spaces:Off ]
    A25: End For
Agenda.tsk.xml

Mike Maynard

unread,
Aug 12, 2012, 12:32:06 PM8/12/12
to tas...@googlegroups.com
I will give it a shot! 

Another thing I have run into on this... is supplying the URL with the proper date format.  Is there a simple way to convert the date from 8-5-2012 to 2012-08-05?

I had built a method last night, but I feared it may be somewhat clunky (this was before I lost all the work in an upgrade....)

Also, me personally should only need 5 events at most.  (although I suppose I could hit the 8-10 on a rare occasion) for a particular day.

Michael Yeager

unread,
Aug 12, 2012, 1:17:02 PM8/12/12
to tas...@googlegroups.com

The routine I put together last night that worked gave me the same result today. I got all the event names clean but the comment data went south after the first few entries. Need to export it and attach but not at my computer. Flipping the date around should be easy enough. I have a routine I stole from another script that breaks it down to month, day, year so putting it back together in one variable is no problem. Tasker has a built in date variable to compare it to. Part of my goal in this is reminding certain friends of certain event by text on the day of the event. For now, these people will be hard coded to keep things simple. Pulling 6 or 8 events gets several days events most of the time so compare on the date will come into play later. Right now I'm still stuck on getting clean data.

easiuser

unread,
Aug 12, 2012, 2:13:03 PM8/12/12
to tas...@googlegroups.com, mmay...@rochester.rr.com
Flipping the date is relatively simple
FlipDate (131)
    A1: Variable Set [ Name:%date To:8-5-2012 Do Maths:Off Append:Off ]
    A2: Variable Split [ Name:%date Splitter:- Delete Base:Off ]
    A3: Variable Set [ Name:%date To:%date3-%date2-%date1 Do Maths:Off Append:Off ]
    A4: Flash [ Text:%date Long:Off ]

easiuser

unread,
Aug 12, 2012, 3:38:41 PM8/12/12
to tas...@googlegroups.com, mmay...@rochester.rr.com
Sorry, should read

A3: Variable Set [ Name:%date To:%date3-%date1-%date2 Do Maths:Off Append:Off ]

easiuser

unread,
Aug 12, 2012, 3:59:43 PM8/12/12
to tas...@googlegroups.com, mmay...@rochester.rr.com
Also routine appears to abort if there is an empty where or content field.  Working on a solution.

Michael Yeager

unread,
Aug 12, 2012, 4:53:28 PM8/12/12
to tas...@googlegroups.com

Are you trying to get just the current day’s events? I was just grabbing the next 8 (at the moment) and was just going to parse through and only use the current day’s events. Seemed like  less work to me. Your way would definitely catch all of the events on the off chance I had more scheduled than I built my routine for but I’m not that busy a guy. Anyhow, I’ll be looking at your idea now too as it very well might be more practical.

 

From: tas...@googlegroups.com [mailto:tas...@googlegroups.com] On Behalf Of Mike Maynard
Sent: Sunday, August 12, 2012 12:32 PM
To: tas...@googlegroups.com
Subject: Re: Processing Google Calendar Data

 

I will give it a shot! 

Mike Maynard

unread,
Aug 12, 2012, 4:59:16 PM8/12/12
to tas...@googlegroups.com

I am only after current day.   Which is easily chosen via the api.

Michael Yeager

unread,
Aug 12, 2012, 5:01:00 PM8/12/12
to tas...@googlegroups.com

I’m glad you figured that out. I’ve been beating my head wondering why it keeps failing to parse the data properly and after you said something it hit me that that was what was happening. It hit a record with no comment and aborted. Added a routine to send myself a text when it was done and tested and sure enough, no text…. As best I can tell, Tasker can handle as many events as it has memory for variables. I hate to think I’m going to have to have a separate task process each event but I guess if there’s no way to proceed after an empty record then at least when the task ended and dropped back to the calling task (if it works that way), then that task would continue to the next event. I lost myself on that idea so if it seems out there, it might be.

 

From: tas...@googlegroups.com [mailto:tas...@googlegroups.com] On Behalf Of easiuser
Sent: Sunday, August 12, 2012 4:00 PM
To: tas...@googlegroups.com
Cc: mmay...@rochester.rr.com
Subject: Re: Processing Google Calendar Data

 

Also routine appears to abort if there is an empty where or content field.  Working on a solution.

Michael Yeager

unread,
Aug 12, 2012, 5:10:47 PM8/12/12
to tas...@googlegroups.com

Nice work! I’m not sure how to handle arrays in Tasker as of yet but your work is definitely going to get a bit of study. I was reading the Google calendar data based of someone else’s script and had no idea that the api was that flexible. Reading today’s events and then processing them, would be easy enough and the api call could be changed to get tomorrows as well without having to specify a set number. Some things I’d like to have a days notice on. It would be nice to be able to pull the comment data but that could be done without if we can’t find a way around the script aborting when it’s empty.

Mike Maynard

unread,
Aug 12, 2012, 9:12:37 PM8/12/12
to tas...@googlegroups.com
So I have started playing with the script that Ron posted.

What I am noticing right off, is it needs something to clear the variables before it runs, otherwise it does funny things (I can handle this - so no need to post it)

I am not sure what you mean about the blank entries causing issues though... trying to re-create it myself.


Mike

Mike Maynard

unread,
Aug 12, 2012, 9:16:54 PM8/12/12
to tas...@googlegroups.com
So maybe I spoke too soon on knowing what I am doing!!

Do I need to use arrayclear for any variable that has been split up?

I guess an example of how to clear them may be in order....

easiuser

unread,
Aug 13, 2012, 1:12:19 AM8/13/12
to tas...@googlegroups.com, mmay...@rochester.rr.com
OK, I cleaned everything up a bit and put the routines in a project.  I haven't extensively tested it but it appears to work with my calendar,  BTW, the arrays did need to be cleared before each run so I created another task to handle this.  You will have to edit the Query variable to your specific calendar. 

GetAgenda will query Google Calendar for the current day's events and parse them.  Had to do some extra tests to account for missing or empty data that may be encountered.  On my non-rooted HTC Inspire it took about 7 seconds to parse 6 events. 

ListEvents will flash the agenda on the screen one at a time.  You will probably need to do some tweaking for your specific purposes (ie read your days agenda, map your routes, etc.)
Agenda.prj.xml

Michael Yeager

unread,
Aug 13, 2012, 9:35:24 AM8/13/12
to tas...@googlegroups.com

Will give this a look see when I get back from running a few errands. I figured out yesterday how to keep it from choking on empty variables. Don’t know if you saw that but it might have helped you. I’m interested to see if your work went the same direction that mine did but I’ve gotta run. I’ll get back here later though….

Michael Yeager

unread,
Aug 13, 2012, 5:14:59 PM8/13/12
to tas...@googlegroups.com
When I split the variable and went to split the result, it there was no data to split, the task would abort and fail to process anything else. I got that figured out. Getting ready to load up the project and check it out now.

Michael Yeager

unread,
Aug 13, 2012, 5:27:25 PM8/13/12
to tas...@googlegroups.com

Hmmm.... Can't get this to import into tasker. Any suggestions on importing the prj.xlm file????

easiuser

unread,
Aug 13, 2012, 5:53:33 PM8/13/12
to tas...@googlegroups.com
Do you have project tabs at the top of your Tasker screen?  If not, you need to turn off beginners mode Menu->Settings->UI uncheck beginners mode.  Should see a faint white arrow below the profiles-tasks-scenes-variables header.  Drag it down.  Long press on the little house tab and import the project file.

Michael Yeager

unread,
Aug 13, 2012, 7:23:52 PM8/13/12
to tas...@googlegroups.com

Already had beginner mode off just didn't know about the arrow.... Now I just have to create a profile to run it...

easiuser

unread,
Aug 13, 2012, 7:34:47 PM8/13/12
to tas...@googlegroups.com
Or a widget or a shortcut.  Just have to assign an icon.

Michael Yeager

unread,
Aug 13, 2012, 9:08:45 PM8/13/12
to tas...@googlegroups.com

Just added you to my chat list but I'm not available very often for chat. Mostly during the day.

Michael Yeager

unread,
Aug 13, 2012, 10:10:39 PM8/13/12
to tas...@googlegroups.com

What are the Param1 and Param2 items for in the first line where is performs the clear arrays task? Couldn’t you have just cleared the arrays as part of the GetAgenda task or did you make it a separate task for a reason? I’m curious, definitely not criticizing. Your work is very nice and I’m hoping to reverse engineer it and understand why things work. Still way to new to Tasker for some things….

 

From: tas...@googlegroups.com [mailto:tas...@googlegroups.com] On Behalf Of easiuser


Sent: Monday, August 13, 2012 1:12 AM
To: tas...@googlegroups.com
Cc: mmay...@rochester.rr.com

Mike Maynard

unread,
Aug 13, 2012, 11:07:04 PM8/13/12
to tas...@googlegroups.com
Ok I just tried this out - and we are making progress!!

but... I do notice if there are a lack of events for the day - it grabs the last day there was events for?  (google flaw??)

Mike Maynard

unread,
Aug 13, 2012, 11:08:48 PM8/13/12
to tas...@googlegroups.com
ok - so its not a google flaw - my phone flaw?

I cleared all the variables to be sure, but somehow its pulling info for calendar entries on 8/11, not 8/13 (just so happens 8/11 is the last day of entries in my calendar)

Mike Maynard

unread,
Aug 13, 2012, 11:14:23 PM8/13/12
to tas...@googlegroups.com
Ok - found a couple of things that are causing this...

Need to make it delete the txt file after the task runs (so bad data doesnt exist for a future run)

may want to have it test for file existence (or at least create a blank file if there are 0 results to prevent task failure)

need to have clear events clear some variables (currently only does arrays, leaving old data behind)

I am going to make some changes on my end....

Mike Maynard

unread,
Aug 13, 2012, 11:22:28 PM8/13/12
to tas...@googlegroups.com
Attached is the file with my adjustments....
Agenda.prj.xml

Michael Yeager

unread,
Aug 13, 2012, 11:23:57 PM8/13/12
to tas...@googlegroups.com, mmay...@rochester.rr.com
I hadn't thought about the occurrence of no data in my original scenario as I was just going to pull the next X events and parse from there. I hadn't researched the Google API for the calendar and had no idea what options were available. You shouldn't need to check for the file to be there as there is going to be at least the header data returned to tell you there are no events that day. Maybe I'm wrong on this as I haven't looked at the file created by the API call you used but there should be. I was going to clear all unnecessary variables at the end of the routine just to keep memory usage down. Grabbing the file a few minutes after midnight and processing it around 7 or so as it's going to generate a few text messages and I don't want to be sending messages to people at midnight. Once it's processed, may clear the array or I may leave it in place to pluck data from during the day. Still don't know how Tasker handles the arrays so I'm going to incorporate the array routines to learn that and to reduce the amount of variables in use.

easiuser

unread,
Aug 13, 2012, 11:24:16 PM8/13/12
to tas...@googlegroups.com
I think param1 and param2 items are blank.  I could have added the lines to the main routine but already had 50+ actions in GetAgenda and it was easy to make it a separate task that I didn't have to scroll through every time I made a change.  Either way works.

Mike Maynard

unread,
Aug 13, 2012, 11:28:21 PM8/13/12
to tas...@googlegroups.com
With the way this is setup, you dont need to run it at midnight.

If you run this at 7am, its still going to grab all data for the day.... 


Deleting the file when done may be excessive, but I had that in my head before I found not all the variables being cleared, so I did both!  Leaving 'old' data laying around is always bad news with something like this (has caused me tons of grief in the past!!)




Now I have to build my scene to display my list and trigger navigation based off it!

Thanks again guys!!

easiuser

unread,
Aug 13, 2012, 11:29:25 PM8/13/12
to tas...@googlegroups.com, mmay...@rochester.rr.com
Its a good idea to delete the text file.  Probably should be done just before you query again so the data is still there if you need it for something else (or to check any errors you might have parsing it)  Just noticed you updated the file, will look at it but probably tomorrow.

Thanks for the suggestions and feedback.  Didn't know it was going to get this big.

Michael Yeager

unread,
Aug 13, 2012, 11:43:19 PM8/13/12
to tas...@googlegroups.com

I had no idea that my little request for a bit of info was going to take on a life of its own. One thing’s for sure, by the time I get done looking at everyone else’s work and reading their input, I’ll have a much better understanding of how Tasker handles some things. Arrays are the focus of my study now as I’ve figured out how to split variables and clean up data. I also figured out how to do a bit of error checking in the process. This little project has become a major learning experience…

Mike Maynard

unread,
Aug 13, 2012, 11:45:32 PM8/13/12
to tas...@googlegroups.com

It just happened to come along on the tail of a thread I had started about my project needs...  

I appreciate all the help,  and it certainly has been a learning experience for me as well!

Michael Yeager

unread,
Aug 13, 2012, 11:47:09 PM8/13/12
to tas...@googlegroups.com

True. It could be downloaded and processed at 7 and still get all the days data…  J Just figured processing it while I’m still in bed would mean that the processing time would mean nothing to me….. If you’re going to get into scenes, give me time to digest what I have as I have no idea what scenes are all about….

Michael Yeager

unread,
Aug 14, 2012, 9:28:29 AM8/14/12
to tas...@googlegroups.com, mmay...@rochester.rr.com
Mike, adding if %item > 0 to your flash agenda task gets rid of the flashing of empty data if there are no events for the day. Doubt it matters as I believe the flash routine was just to show the data but it might be useful to you in the future. I am going to spend a good part of my day getting familiar with the way you handled the array. I also noticed that %item was all lowercase and not visible in the variables list after the routine ran. Does it clear itself at the end of the task? I read somewhere that if you want to use a variable outside of the task that created it then it had to start with an uppercase letter. If this is correct and they clear automatically at the end of a task otherwise, this is good information as well...
Message has been deleted

easiuser

unread,
Aug 14, 2012, 11:39:17 AM8/14/12
to tas...@googlegroups.com, mmay...@rochester.rr.com
Correct, the flash routine was just to display info for debugging.  Tasker does clear local variables which are all lowercase.  Any capital letter, not just the first, will make a variable global and therefore accessable to other tasks.  I used the global variables because they persist which is useful while debugging.  I will probably modify the routine to just use local variables and write the info to a structured text file for use by other routines.  Just no time atm.

Michael Yeager

unread,
Aug 14, 2012, 11:51:09 AM8/14/12
to tas...@googlegroups.com

No problems either way, I'm just learning what I can. Still working on digesting the array information. Got a little sidetracked or I'd already have it plotted out.

Mike Maynard

unread,
Aug 14, 2012, 3:05:27 PM8/14/12
to tas...@googlegroups.com

Did you guys notice the date not working properly?   I had to add a check that adds a 0 in front of the month and day to fervor to work properly with google.

Michael Yeager

unread,
Aug 14, 2012, 3:14:06 PM8/14/12
to tas...@googlegroups.com

Seemed to be working ok… Where did you have to add a check?

 

 

From: tas...@googlegroups.com [mailto:tas...@googlegroups.com] On Behalf Of Mike Maynard
Sent: Tuesday, August 14, 2012 3:05 PM
To: tas...@googlegroups.com
Subject: Re: Processing Google Calendar Data

 

Did you guys notice the date not working properly?   I had to add a check that adds a 0 in front of the month and day to fervor to work properly with google.

Mike Maynard

unread,
Aug 14, 2012, 3:16:34 PM8/14/12
to tas...@googlegroups.com

Before that query variable is built,  I check DATE1 and DATE2 separately with an idea statement, if they are less than 10, I place a 0 in front of them.

Michael Yeager

unread,
Aug 14, 2012, 4:49:06 PM8/14/12
to tas...@googlegroups.com

Oh, I thought the system date variable came already formatted with the leading zero. I looked at it but seeing as calling the API in the manner was not my idea at all, I didn’t look too hard at it. Would you believe I’m still trying to wrap my brain around the variable use in this script? I’m not having issues with the array at all, it’s a few of the local variables I’m still trying to understand. I’m pretty sure I understand the way they were used, maybe I’m just still wondering how someone would come up with that idea. Been out of programming WAY too long….

 

From: tas...@googlegroups.com [mailto:tas...@googlegroups.com] On Behalf Of Mike Maynard
Sent: Tuesday, August 14, 2012 3:17 PM
To: tas...@googlegroups.com
Subject: RE: Processing Google Calendar Data

 

Before that query variable is built,  I check DATE1 and DATE2 separately with an idea statement, if they are less than 10, I place a 0 in front of them.

Michael Yeager

unread,
Aug 14, 2012, 4:57:13 PM8/14/12
to tas...@googlegroups.com

Ok, screw it. I’m going to ask… Where did the variables %item, %item2 come from??? I see where last is defined but the other two are escaping me. Is this some neat built in Tasker routine? Please explain how it works or point me to a reference so I can read it for myself.

 

Thanks!!!

 

From: tas...@googlegroups.com [mailto:tas...@googlegroups.com] On Behalf Of Mike Maynard
Sent: Tuesday, August 14, 2012 3:17 PM
To: tas...@googlegroups.com
Subject: RE: Processing Google Calendar Data

 

Before that query variable is built,  I check DATE1 and DATE2 separately with an idea statement, if they are less than 10, I place a 0 in front of them.

easiuser

unread,
Aug 14, 2012, 7:24:29 PM8/14/12
to tas...@googlegroups.com
The text file is broken up into sections with each event put in %Event2, %Event3, and so on.  As the for loop goes through the array, %item is set to %EventX.

Michael Yeager

unread,
Aug 14, 2012, 8:53:51 PM8/14/12
to tas...@googlegroups.com

I wrote this to process the dates in the array to a more friendly format. Don't know if I could have made it smaller but I suspect it could be. Going to incorporate it all into one routine when all the bugs are out and I figure out how I want to do it..

Test (40)
A1: Variable Set [ Name:%item To:%cntEvents Do Maths:Off Append:Off ]
<Date Loop>
A2: Variable Set [ Name:%start To:%EventStart(%cntEvents) Do Maths:Off Append:Off ]
A3: Variable Split [ Name:%start Splitter:T Delete Base:Off ]
A4: Variable Split [ Name:%start1 Splitter:- Delete Base:Off ]
A5: Variable Split [ Name:%start2 Splitter:: Delete Base:Off ]
A6: Variable Set [ Name:%start25 To:am Do Maths:Off Append:Off ]
A7: Variable Set [ Name:%start25 To:pm Do Maths:Off Append:Off ] If [ %start21 > 11 ]
A8: Variable Set [ Name:%start21 To:%start21*1 Do Maths:On Append:Off ]
A9: Variable Set [ Name:%start21 To:%start21-12 Do Maths:On Append:Off ] If [ %start21 > 12 ]
A10: Variable Set [ Name:%start21 To:12 Do Maths:Off Append:Off ] If [ %start21 ~ 0 ]
A11: Variable Set [ Name:%start To:%start12/%start13 at %start21:%start22%start25. Do Maths:Off Append:Off ]
A12: Array Push [ Name:%EventStart Position:1 Value:%start Fill Spaces:Off ]
A13: Variable Set [ Name:%end To:%EventEnd(%cntEvents) Do Maths:Off Append:Off ]
A14: Variable Split [ Name:%end Splitter:T Delete Base:Off ]
A15: Variable Split [ Name:%end1 Splitter:- Delete Base:Off ]
A16: Variable Split [ Name:%end2 Splitter:: Delete Base:Off ]
A17: Variable Set [ Name:%end25 To:am Do Maths:Off Append:Off ]
A18: Variable Set [ Name:%end25 To:pm Do Maths:Off Append:Off ] If [ %end21 > 11 ]
A19: Variable Set [ Name:%end21 To:%end21*1 Do Maths:On Append:Off ]
A20: Variable Set [ Name:%end21 To:%end21-12 Do Maths:On Append:Off ] If [ %end21 > 12 ]
A21: Variable Set [ Name:%end21 To:12 Do Maths:Off Append:Off ] If [ %end21 ~ 0 ]
A22: Variable Set [ Name:%end To:%end12/%end13 at %end21:%end22%end25. Do Maths:Off Append:Off ]
A23: Array Push [ Name:%EventEnd Position:1 Value:%end Fill Spaces:Off ]
A24: Variable Subtract [ Name:%item Value:1 ]
A25: Goto [ Type:Action Label Number:1 Label:Date Loop ] If [ %item > 0 ]
A26: Perform Task [ Name:Process Events Stop:Off Priority:5 Parameter 1 (%par1): Parameter 2 (%par2): Return Value Variable: ]

Michael Yeager

unread,
Aug 14, 2012, 10:56:23 PM8/14/12
to tas...@googlegroups.com

Here's the xml....

Test.tsk.xml

Michael Yeager

unread,
Aug 14, 2012, 11:14:32 PM8/14/12
to tas...@googlegroups.com

Is that what this does?

 

A15: For [ Variable:%item Items:%Event(2:%last) ]

easiuser

unread,
Aug 15, 2012, 9:28:05 AM8/15/12
to tas...@googlegroups.com
Yes

Michael Yeager

unread,
Aug 15, 2012, 4:45:29 PM8/15/12
to tas...@googlegroups.com
Ok, I'm still tweaking the hell out of all of this to get exactly what I want but I have noticed that it leaves an ever growing list of variables behind. %EventTitle and %EventWhere are the big offenders. I've made multiple attempts to clean these up with a loop using Variable Clear %EventWhere(%item) but it doesn't seem to work. Am I trying to clear array data with that argument???

easiuser

unread,
Aug 15, 2012, 5:37:41 PM8/15/12
to tas...@googlegroups.com
I rewrote this program that parses the data and writes a file with a line for each event.  I don't use any global variables so no need to clear them as they will get destroyed when the parsing routine ends.  Then with two statements you can read the event in and split it with a ^.  I use it to speak my agenda for the day when I begin my commute.  You could easily modify it to display an agenda in a minimalist text widget, map the locations or whatever.  I will post it later today.  Here is a couple sample lines in the events.txt file that gets generated.  Note I split the start and end date/time.
 
Appointment 1 Subject^Location for appointment 1^Description of appointment 1^08-15-2012^12:30:00^08-15-2012^13:00:00^
Appointment 2 Subject^Location for appointment 2^Description of appointment 2^08-15-2012^14:15:00^08-15-2012^18:00:00^
 
BTW -  There is an Array Clear action which should delete all the elements.

easiuser

unread,
Aug 15, 2012, 10:17:26 PM8/15/12
to tas...@googlegroups.com
Here is a cleaned up version that does not use any global variables as described above.  Additionally I processed the raw data in reverse so the output file should be in chronological order.  The two files created gcaldata.txt (raw feed from google calendar) and events.txt (structured file containing the events, 1 event per line, properties separated by a ^.  I placed the files in the data/Agenda directory to keep it isolated from other files.  You can obviously change this as you require.  The following is included in the project file:

Profile DownloadAgenda - runs GetAgenda after midnight to get the days appointments

Task GetAgenda - Downloads data from Google Calendar, parses the data and stores it in a structured file. (edit as required to change the %query variable for your calendar and time span)  This took about 20 seconds for me to process 10 appointments in a single day.
Task ReadAgenda - Speaks your agenda with some human readable adjustments made to the date/time
Task FlashAgenda - Simply flashes each appointment (not of much use really) but shows how easy it is to read in the data.

You should be able to customize this to do whatever you want to do with your google calendar data.  Hope you find it useful.
Agenda.prj.xml

Michael Yeager

unread,
Aug 15, 2012, 10:35:53 PM8/15/12
to tas...@googlegroups.com
Another thing I may have found (and I may have created this myself) is that if I have all day events two days in a row, it seems to pick up the next days full day event a day early. Still testing by clearing all the extra variables by hand so I'll check it out tomorrow. Guess I'm going to have to combine it all to one task and use all local variables so there's nothing left after it runs. I understand why you're writing it to a file, otherwise it's all lost at the end of the task...

easiuser

unread,
Aug 16, 2012, 10:33:53 AM8/16/12
to tas...@googlegroups.com
Just noticed the same thing.  It happens when there is an all day event for the next day.  Google may be including it due to a reminder being set which would happen just before midnight.  Also the data downloaded is structured a bit different than a normal appointment (including no time value, just a date)  Will have to debug and repost. Also looks like the appointments are returned in the order created and not sequentially so I will have to do some additional sorting before writing the output. I'll try to get to it over the weekend. 

Michael Yeager

unread,
Aug 16, 2012, 11:11:30 AM8/16/12
to tas...@googlegroups.com

I have tested it with no reminder set and it still downloaded the next day event. No real big deal here as I can either ignore it or flag it as an all day event for tomorrow and deal with it as such. I guess I’ll wrap all of what I have now into one task and use local variables only and see where that gets me. Harder to debug that way but I can set other variables temporarily to see what I need to see. The variables that are left over don’t appear to be part of the array (I don’t think you can see the array in the variables list) but I could be wrong.

 

From: tas...@googlegroups.com [mailto:tas...@googlegroups.com] On Behalf Of easiuser
Sent: Thursday, August 16, 2012 10:34 AM
To: tas...@googlegroups.com
Subject: Re: Processing Google Calendar Data

 

Just noticed the same thing.  It happens when there is an all day event for the next day.  Google may be including it due to a reminder being set which would happen just before midnight.  Also the data downloaded is structured a bit different than a normal appointment (including no time value, just a date)  Will have to debug and repost. Also looks like the appointments are returned in the order created and not sequentially so I will have to do some additional sorting before writing the output. I'll try to get to it over the weekend. 

easiuser

unread,
Aug 25, 2012, 9:05:13 PM8/25/12
to tas...@googlegroups.com
OK. I got it fairly functional. I use it to get my personal and work agenda for the next 2 days and have it read over my car's BT during my commute.  I would be interested if it works for you or anyone else.  This may all be for nought if the future calender event action ever gets implemented in Tasker.  It's on the extensive todo list.  If it works for others, I might post it on the Tasker Wiki.


On Thursday, August 9, 2012 10:30:46 PM UTC-5, Michael Yeager wrote:
I have seen many instances of downloading the calendar data to a text file and parsing it from there so I'm not totally lost, however I don't understand how the data is being parsed and looking at the data from several tasks I've downloaded doesn't help much. What I want to do is look at my calendar entries each morning and then process tasks by the days events. I only need it to run once each day but I want it to handle all of the days events. My task can loop and handle each entry one at a time as far as I'm concerned. I see the calendar entry state but I don't think this will be very helpful in this. If I'm wrong, please educate me on the use of the calendar entry state. New to Tasker but I'm learning, even if so far it's mostly by tearing apart something that someone else has done and reverse engineering it. Thanks ahead of time for any help I get...
Agenda readme.htm
Agenda.prj.xml

Michael Yeager

unread,
Aug 27, 2012, 6:08:45 PM8/27/12
to tas...@googlegroups.com

I’ll give it a run in the next few days and let you know. I’ve got it to do pretty much what I wanted but I will learn from your project and probably steal a few things while I’m at it. Always looking for new ideas and methods…

 

From: tas...@googlegroups.com [mailto:tas...@googlegroups.com] On Behalf Of easiuser
Sent: Saturday, August 25, 2012 9:05 PM
To: tas...@googlegroups.com
Subject: Re: Processing Google Calendar Data

 

OK. I got it fairly functional. I use it to get my personal and work agenda for the next 2 days and have it read over my car's BT during my commute.  I would be interested if it works for you or anyone else.  This may all be for nought if the future calender event action ever gets implemented in Tasker.  It's on the extensive todo list.  If it works for others, I might post it on the Tasker Wiki.




On Thursday, August 9, 2012 10:30:46 PM UTC-5, Michael Yeager wrote:

gary scarborough

unread,
Jun 26, 2013, 8:22:55 PM6/26/13
to tas...@googlegroups.com
I know Im a year late on this but i downloaded the project and i have been trying to figure out how to get this to read or display the calendar events but I dont have a clue how to is anyone still monitoring this post that can help?
 

On Tuesday, November 20, 2012 5:03:17 PM UTC-5, Michael Tripp wrote:
I ran into a problem with this but it wasn't with tasker, it was actually the first line.
Agenda (117)
    A1: HTTP Get [ Server:Port:https://www.google.com/calendar/feeds/xxx%40gmail.com/private-xxx/full?start-min=2012-08-11T00:00:00&start-max=2012-08-11T23:59:59 Path: Attributes: Cookies: Timeout:67 Mime Type: Output File:agenda.txt ] 
the Time(T00:00:00 and T23:59:59) is GMT, which means you have to adjust for the timezone your calendar is in. For example mine is Eastern Standard or GMT -5:00 so I had to amend the times with (.000-5:00) so now they read (T00:00:00.000-5:00 and T23:59:59.000-5:00). 
It took me a while to figure this out, just thought it may help someone else.

On Sunday, August 12, 2012 1:59:19 AM UTC-4, easiuser wrote:
Mike,  You prompted me to parse my own data.  When ran, your event data should be in their respective array variables.  I don't know how many events Tasker can handle, but I hope it works for you.

Agenda (117)
    A1: HTTP Get [ Server:Port:https://www.google.com/calendar/feeds/xxx%40gmail.com/private-xxx/full?start-min=2012-08-11T00:00:00&start-max=2012-08-11T23:59:59 Path: Attributes: Cookies: Timeout:67 Mime Type: Output File:agenda.txt ]
    A2: Read File [ File:agenda.txt To Var:%myAppt ]
    A3: Variable Split [ Name:%myAppt Splitter:<openSearch:totalResults> Delete Base:Off ]
    A4: Variable Split [ Name:%myAppt2 Splitter:</openSearch:totalResults> Delete Base:Off ]
    <%cntEvents is the number of events returned>
    A5: Variable Set [ Name:%cntEvents To:%myAppt21 Do Maths:Off Append:Off ]
    A6: Variable Set [ Name:%Event To:%myAppt22 Do Maths:Off Append:Off ]
    <Splits file into %Events2,3,4,...>
    A7: Variable Split [ Name:%Event Splitter:#kind Delete Base:Off ]
    A8: Variable Set [ Name:%last To:%cntEvents+1 Do Maths:On Append:Off ]

Michael Yeager

unread,
Jun 27, 2013, 9:10:12 AM6/27/13
to tas...@googlegroups.com

Still around. I can send you my routine that pulls all events for the current day if you like. It's not been improved in quite some time but it works. At least it will give you a working start.

--
You received this message because you are subscribed to a topic in the Google Groups "Tasker" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tasker/eO1OYspNCuA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tasker+un...@googlegroups.com.
Visit this group at http://groups.google.com/group/tasker.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

gary scarborough

unread,
Jun 27, 2013, 9:56:01 PM6/27/13
to tas...@googlegroups.com
yes please send me your routine i could really use the help and thank you very much
--
Gary Scarborough

Michael Yeager

unread,
Jun 27, 2013, 10:52:35 PM6/27/13
to tas...@googlegroups.com

Already posted it....  Can email the xml if needed. Kinda long to plug in one line at a time.....

gary scarborough

unread,
Jun 28, 2013, 8:50:48 AM6/28/13
to tas...@googlegroups.com
If you wouldn't mind email the XML file. I can't wait to try out. Thank you again

Gary
Sent from my iPad

easiuser

unread,
Jun 28, 2013, 9:46:48 AM6/28/13
to tas...@googlegroups.com
 If your rooted, I would suggest you check out https://groups.google.com/forum/?fromgroups=#!topic/tasker/BecVXt-Yuks%5B1-25-false%5D which uses a sqlite query to get the information straight from your phone.  I ended up abandoning this method because it became quite slow with a lot of events to parse. 

gary scarborough

unread,
Jun 28, 2013, 12:53:15 PM6/28/13
to tas...@googlegroups.com

Thanks for the link I will try this method for getting the information.

Michael Yeager

unread,
Jun 28, 2013, 1:04:20 PM6/28/13
to tas...@googlegroups.com

I'm going to look at it as well. My code is old, crude and limited in its abilities. It does the job I wanted it to do at the time but I have no doubt it could have been better.

gary scarborough

unread,
Jun 28, 2013, 2:02:32 PM6/28/13
to tas...@googlegroups.com

I'm surprised no one has come up with a taker app to do this

Mike Yeager

unread,
Jun 28, 2013, 2:56:14 PM6/28/13
to tas...@googlegroups.com
There are tons of ways to do this and I'm not sure there's that much demand for an actual app. I could be wrong but the app would have to be pretty customizable to fit everyone's needs that tried to use it. Also likely require root which limits the user base.

On 6/28/2013 2:02 PM, gary scarborough wrote:

gary scarborough

unread,
Jun 28, 2013, 3:33:52 PM6/28/13
to tas...@googlegroups.com

I guess your right I'm use to be rooted

Reply all
Reply to author
Forward
0 new messages