Anthonys Germa

Q: How to convert work schedule in .csv to iCal without birthday bug

Hey all!

 

I followed a topic about converting a CSV schedule into a ICAL event (moderated by Austin Kinsella1) and everything seems nearly perfect to me but there's a mistake in the script that my poor knowledge can't fix: When I drop my CSV schedule on the App created with the script, it works but.. appears as a birthday (not attached to a contact though) in my calendar, no matter which Calendar I chose when I'm asked...

 

If someone could help that would be really nice! Here find the script:

 

--AK Mar 2005

--make iCal events from a dropped spreadsheet

--assume  events in first sheet

--one event per row

--1st row is header with labels Title,Start,End (any order, gaps acceptable)

--also process Location and Description cols if present

--prompt for calendar to get the events

--could use some error handling

on open DroppedFile

          tell application "Microsoft Excel"

  open DroppedFile

                    set UsedCells to value of used range of sheet 1

  quit --remove this if Excel sholud stay open

          end tell

          set SummaryCol to FindInList("Title", item 1 of UsedCells)

          set StartCol to FindInList("Start", item 1 of UsedCells)

          set EndCol to FindInList("End", item 1 of UsedCells)

          tell application "iCal"

                    set CalList to title of every calendar

          end tell

          set Chosen to choose from list CalList with prompt "Choose calender for the new events"

          if Chosen is not false then

                    set TheCalendar to FindInList(Chosen, CalList)

                    if (SummaryCol > 0) and (StartCol > 0) and (EndCol > 0) then --REQUIRE Title, Start and End

                              set DescripCol to FindInList("Description", item 1 of UsedCells) --look for additional items

                              set LocCol to FindInList("Location", item 1 of UsedCells)

                              if (count of item 1 of UsedCells) > 1 then --there are some data rows

                                        set UsedCells to rest of UsedCells

                                        repeat with AnEvent in UsedCells

                                                  set theSummary to (item SummaryCol of AnEvent)

                                                  set TheStart to (item StartCol of AnEvent)

                                                  set TheEnd to (item EndCol of AnEvent)

                                                  tell application "iCal"

                                                            tell calendar TheCalendar

                                                                      set CalEvent to make new event at end of events with properties{summary:theSummary, start date:TheStart, end date:TheEnd}

                                                                      if LocCol > 0 then set location of CalEvent to item LocCol of AnEvent

                                                                      if DescripCol > 0 then set description of CalEvent to item DescripColof AnEvent

                                                            end tell --calendar

                                                  end tell --iCal

                                        end repeat --AnEvent

                              end if --are datarows

                    else

                              display dialog "Spreadsheet must have Title, Start, and End columns" with icon stop

                    end if --missing headers

          end if --no calendar selected

end open

 

on FindInList(Needle, HayStack)

          set FoundAt to 0

          if Needle is in HayStack then

                    repeat with FoundAt from 1 to count of HayStack

                              if Needle is item FoundAt of HayStack then exit repeat

                    end repeat

          end if

          return FoundAt

end FindInList

 

Message was edited by: Anthonys Germa

MacBook Pro (Retina, 13-inch, Mid 2014), iOS 9.3, null

Posted on Mar 28, 2016 8:44 AM