Integrating python and Google calendar?

Hi friends,
This is my first post here. Please forgive me as I am a complete novice with Python. I have experience with HTML and CSS, but my main gig is electronics...So, please excuse me if I am out of line asking this question here!

A friend was helping me build a script using Python to integrate with my Google Calendar. I have a band, and I was wanting an app that could input one date (gig) and then several other events would auto-populate into the calendar (IE: 14 days before send out fliers, 2 days after send out thank you emails, etc).

I got Python installed and the code does the basic job. He has the Python code link to a CSV file and I open up a DOS command prompt and enter the fields and everything populates fine.

To add more information to your events, simply add more headers. Possible headers include: Subject, Start Date, Start Time, End Date, End Time, All Day Event, Description, Location, and Private.

So this was my long winded way of asking my question:
How can I add all these other headers into the above python code? I have read a lot on the google pages, but I just don't know enough about this stuff to understand most of what is being talked about. I'm sure the answer is somewhere HERE, but I don't know where!

You could add other headers by writing something like the following into that block of code, after event.minute = int(minute) . Like this:

event.location = item[3]

and change the CSV file to have an extra value at the end of the line, so it looks like this:

"-2","Send out email","12:00","home"

In the above case, I used index 3 (indices start on zero) as the location header of the event. This is why I used item[3] in the above Python. So now this event has the location set to 'home'. I'm not sure about all the Python variables used for the various headers, but I'm guessing they follow the format of the header with spaces turned to underscores, and in all lower-case letters. I'm guessing here, but the header 'All Day Event' probably is 'all_day_event' in python.
The CSV file seems to be organized at your own whim (as far as I could find), so keep track of the order of the headers on the line, so in Python, you can call event.HEADER = item[INDEX] for in this same code block as above, where HEADER is the Python variable for a header, and INDEX is the location of it on the CSV file's line.

I've never used Google Calender, but I just glanced through those links you provided and the sample with the location header I provided seems to be logical. Tell me if it works, or if you need any other help!

Thanks for the reply shadwickman. Those changes didn't break the code, but it didn't give any results. The location did not import into the "Where" field on google calendar. I did find this-again sadly I don't really know if this info helps...Elements: "Kinds".

One thing I'm confused about though from your post is that I need to be able to edit the variables like location. If I just put "home" in the CSV, then the location would always be "home"...

So to be clear, what I need to be able to do is edit more of the fields of the "primary date", but all the secondary 'auto-populated' dates will have built in values that would be predetermined (I guess with the CSV)

Forgive me if it's too much, but I'll include all the python code to give a better description of what is happening with the DOS input. (forgive the humor that my friend included in the coding!)

The DOS then asks me for the date of the gig and the time of the gig. If I don't answer these values, it doesn't let me go further.

Then the DOS asks me for a short description of the gig.

2) THen Python adds the gig whose Info I put in onto Google calendar and then populates the other dates based on the CSV file.

So the added functionality I am needing is twofold:

1) I need to have other fields (like location, etc, etc) that can be read from the CSV,

and 2) I need other prompts requested of me from the DOS (also things like location, start and end time, etc, etc).

Thoug these two tasks seem similar, I believe they are two different areas of the above code that need to be addresse (one for the DOS and one for the CSV)

I hope this makes sense?

To be more clear: When I put a gig into the calendar, I am wanting to choose a predetermined CSV file that will have a "promotion timeline" that will be based on what type of gig it is (IE I will have a "local" and a "regional" CSV list because my promotion timeline will be different for both) These CSV lists won't need to change from gig to gig-I can edit them over time as my needs change.

But the fields that the DOS is asking me for for each specific gig need to give me more options than just the date, time, and short description...

I would suggest you try this with your old CSV structure until you are sure it's working but that's up to you.
You would probably want to alter your custom CalendarEvent to include a where field after getting this to work.

You need to add a location field to the end of each CSV line for this to work.

So that takes care of locations for promotional events.

Now you need to ask for a gig location:

# Prompt for the gig date
gig_date = get_gig_date()
# Get a location of the gig
gig_location = raw_input("Location of the gig: ")
# Get a description of the gig
gig_description = raw_input("Short description of the gig: ")

I wrote a long reply, but I did it in the quick reply box and unfortunately got logged out before I could send it...

In short...IT WORKS!!!

Not only does it work, but your teaching enabled me to also create another field for "content" to add a longer description using the atom:content.

Thank you!

I'm hesitant to ask, and you can please feel free to tell me to take a hike...there are a couple other things that I'm not understanding.

1) for some reason the times I am entering in the DOS and CSV are being pushed back 6 hours on Google calendar (some kind of time-change thing?) Also related to the time, I don't have this code set up to get both a start and end time-as it is now it just gives the start time and makes the event one hour long...

2) This seems tricky to me, but would be pretty important...How could I link the date or title of the gig I am entering with the CSV events? The reason is because if we have something like 20 gigs in the month, we will need to know which gig we are promoting when the reminder pops up. The easiest way from a user standpoint would be to have the date or the title (description) of the gig in the description of the promotion event. Any idea on that one?

Again, thank you SO MUCH for your help! I have been struggling with this for weeks and weeks...you have really taught me a lot!

1) for some reason the times I am entering in the DOS and CSV are being pushed back 6 hours on Google calendar (some kind of time-change thing?) Also related to the time, I don't have this code set up to get both a start and end time-as it is now it just gives the start time and makes the event one hour long...

Then ask the user for input, like we did when adding the location field.
You then set end_time near the end of the script to equal this time that you requested from the user.

2) This seems tricky to me, but would be pretty important...How could I link the date or title of the gig I am entering with the CSV events? The reason is because if we have something like 20 gigs in the month, we will need to know which gig we are promoting when the reminder pops up. The easiest way from a user standpoint would be to have the date or the title (description) of the gig in the description of the promotion event. Any idea on that one?

You said you added "content" for longer descriptions. You could modify that like this:

Adding the time change didn't seem to do anything. i remember my friend who originally built this saying he couldn't figure out how to get the time right...he seemed to think it was a Google bug...I don't know.

Then ask the user for input, like we did when adding the location field.

OK, that all looks like this now:

# First, get a list of all the CSV files in the install root directory sorted alphabetically. Make an event factory for each.
csv_files = list_csv_files(install_root)
# Next, print a menu and get the index of the option they want.
index = display_menu(csv_files)
# Prompt for the gig date
gig_date = get_gig_date()
# Get the end time of the gig
end_time = raw_input("End Time: ")
# Get a location of the gig
gig_location = raw_input("Location of the gig: ")
# Get a title for the gig
gig_title = raw_input("Title of the event: ")
# Get a long description for the gig
gig_content = raw_input("Details: ")

You then set end_time near the end of the script to equal this time that you requested from the user.

OK, you lost me...

I know it's in here, but I see some values already done for the end time, so I'm not sure if anything needs to go:

I didn't answer your question. The time issue is not resolved. Worse case, I can offset things on my end by 6 hours as a work around. The big question I have (and hopefully would be a fast and easy response) is with this:

You said you added "content" for longer descriptions. You could modify that like this:

For some reason, I posted code with errors above. The working code is below (less the changes you just posted-which I will do now).

I had an issue with the start and stop time. You can see in the below code that my friend had put the date and the time of the gig as one line requested by the DOS. Thanks to your help, I know how to break the DOS request into two lines, but I don't know how to separate out the code to handle them as two separate events. I'm thinking that might be what is hindering the end_time request? I highlighted the bits that I'm talking about.

I understand that I may well just be asking too much from a stranger on a forum in which I am a newbie, so I really do apologies and thank you for your time.

There are a couple things I'm trying to iron out here to make this useable...

Adam1122, you have been SO HELPFUL in getting me to where I am! Thank you so much! I'm wondering if anyone will be able to help carry me through this last little stretch?

THere are two main issues:
1) I haven't figured out how to make a gig event have a start and end time. Also the times are all shifted back 6 hours from what in input on the CSV and the DOS.

2) I have set the calendar up so that when I put an event in the calendar, it automatically adds a reminder to email me when that event happens. I have a filter set up in my gmail inbox to forward that specific event title to one of my bandmates to do the task. It works absolutely beautiful, the ONLY PROBLEM is for some reason the events added via Python are not getting that reminder automatically added? Any event I manually input does get one...

There are a couple things I'm trying to iron out here to make this useable...

Adam1122, you have been SO HELPFUL in getting me to where I am! Thank you so much! I'm wondering if anyone will be able to help carry me through this last little stretch?

THere are two main issues:
1) I haven't figured out how to make a gig event have a start and end time. Also the times are all shifted back 6 hours from what in input on the CSV and the DOS.

2) I have set the calendar up so that when I put an event in the calendar, it automatically adds a reminder to email me when that event happens. I have a filter set up in my gmail inbox to forward that specific event title to one of my bandmates to do the task. It works absolutely beautiful, the ONLY PROBLEM is for some reason the events added via Python are not getting that reminder automatically added? Any event I manually input does get one...

Hoping for a miracle!

Sincerely,
Joel

I didn't entirely forget about you. I might get a chance tomorrow to check into your problems. I don't know if someone else can help you in the meantime.

As for the time offset issue, change instances of %Y-%m-%dT%H:%M:%S.000Z to %Y-%m-%dT%H:%M:%S . That should make all event times right for the time zone you have set for that calendar.

I have a 2d matrix with dimension (3, n) called A, I want to calculate the normalization and cross product of two arrays (b,z) (see the code please) for each column (for the first column, then the second one and so on).
the function that I created to find the ...

Write a C program that should create a 10 element array of random integers (0 to 9). The program should total all of the numbers in the odd positions of the array and compare them with the total of the numbers in the even positions of the array and indicate ...