Previous 1 2 Next 15 Replies Latest reply: Apr 5, 2014 12:22 PM by AlanSelby
Fred Davenport Level 1 Level 1 (0 points)
Can I import my schedules that we keep in Excel into iCal?

Hope this is something simple.

Mac Book Pro, Mac OS X (10.6.1)
  • Austin Kinsella1 Level 6 Level 6 (11,520 points)
    If you make a comma-separated values file, you can use an Applescript such as the sample below to import them.

    AK

    <pre style="font-family: 'Monaco', 'Courier New', Courier, monospace; overflow:auto; color: #222; background: #DDD; padding: 0.2em; font-size: 10px; width:400px">--Convert CSV file to iCal events
    --Prompts for file, then processes
    --expects date,start time,end time,event name,xxxx,calendar name
    --eg 12/01/2006,20:30,22:00,Water Committee,,TestCal
    --change the various text item ns if data order in a file line is different
    --blank lines skipped
    --if other data present (eg location, notes ...) add a line in the tell calendar Calno loop
    --to include it eg set location to text item 5 of ThisLine
    set OldDelimiters to AppleScript's text item delimiters
    set LF to ASCII character 10
    set theFile to choose file with prompt "Select CSV calendar file"
    set theLines to read theFile
    set AppleScript's text item delimiters to {LF}
    set theLines to paragraphs of theLines
    set AppleScript's text item delimiters to {","}
    repeat with ThisLine in theLines
    if (count of ThisLine) > 0 then --ignore blanks
    set StartDate to date (text item 1 of ThisLine & " " & text item 2 of ThisLine)
    set EndDate to date (text item 1 of ThisLine & " " & text item 3 of ThisLine)
    set CalName to word 1 of text item 6 of ThisLine
    tell application "iCal"
    set CalList to title of every calendar
    if CalName is in CalList then
    repeat with CalNo from 1 to count of CalList
    if CalName is item CalNo of CalList then exit repeat
    end repeat
    else
    set NewOne to make new calendar at end of calendars with properties {title:CalName}
    set CalNo to 1 + (count of CalList)
    end if
    tell calendar CalNo
    set newItem to make new event at end of events with properties {start date:StartDate}
    set summary of newItem to text item 4 of ThisLine
    set end date of newItem to EndDate
    end tell --calendar
    end tell --iCal
    end if
    end repeat
    set AppleScript's text item delimiters to OldDelimiters</pre>
  • Fred Davenport Level 1 Level 1 (0 points)
    Thx AK,

    Looks like the answer is NO. That is too bad.

    Your work-a-round script is a little too much for me. Have also thought scripts are band-aids for bad software.

    Incredible that iCal does not allow simple importing from Excel, text and comma files.

    I currently export my spreadsheet as a text/tab delimited file, then import to Palm software, export as a vcal file, then import to iCal.

    Was hoping that iCal would finally have a simple import from text and comma files.

    Oh well, thanks much for your help.
  • Austin Kinsella1 Level 6 Level 6 (11,520 points)
    You could use the script with tab-delimited files by changing


    set AppleScript's text item delimiters to {","}


    to


    set AppleScript's text item delimiters to {tab}


    and save yourself a couple of steps.

    Have also thought scripts are band-aids for bad software

    We have a philosophical difference here - I prefer my software to be minimalistic in features but easy to integrate into a workflow or expand.

    AK
  • Fred Davenport Level 1 Level 1 (0 points)
    Thx AK,

    I am very, very frustrated that iCal cannot import simple text and we all have to do work-a-rounds and use scripts.
  • Sarone Level 1 Level 1 (0 points)
    **** All!
    I have been trying to do this for a while!! Using the script above, for the first time, i was able to import events from excel to ical.

    One question for John would be "How can I add location to events that are created?" The current script created the events, start and finish time as well as the event name into the appropriate calendar but seemed to skip over the location.

    Thanks a lot for making my life dramatically easier.
  • Sarone Level 1 Level 1 (0 points)
    Sorry AK

    Gave credit to John. He had something similar on another thread. Your script worked great. Was able to modify the script to add location. THANKS a lot!! This is Awesome.

    This is what the script looks like:


    set OldDelimiters to AppleScript's text item delimiters
    set LF to ASCII character 10
    set theFile to choose file with prompt "Select CSV calendar file"
    set theLines to read theFile
    set AppleScript's text item delimiters to {LF}
    set theLines to paragraphs of theLines
    set AppleScript's text item delimiters to {","}
    repeat with ThisLine in theLines
    if (count of ThisLine) > 0 then --ignore blanks
    set StartDate to date (text item 1 of ThisLine & " " & text item 2 of ThisLine)
    set EndDate to date (text item 1 of ThisLine & " " & text item 3 of ThisLine)
    set CalName to word 1 of text item 6 of ThisLine
    tell application "iCal"
    set CalList to title of every calendar
    if CalName is in CalList then
    repeat with CalNo from 1 to count of CalList
    if CalName is item CalNo of CalList then exit repeat
    end repeat
    else
    set NewOne to make new calendar at end of calendars with properties {title:CalName}
    set CalNo to 1 + (count of CalList)
    end if
    tell calendar CalNo
    set newItem to make new event at end of events with properties {start date:StartDate}
    set summary of newItem to text item 4 of ThisLine
    set location of newItem to text item 5 of ThisLine
    set end date of newItem to EndDate
    end tell --calendar
    end tell --iCal
    end if
    end repeat
    set AppleScript's text item delimiters to OldDelimiters

    Excellent!!
  • Don.a.dio Level 1 Level 1 (0 points)
    You can save it as a csv file that can be imported to Google Calendar. From there, you can add your google account in ical.

    Directions to properly format the csv file in excel are provided by Google:

    https://www.google.com/support/calendar/bin/answer.py?hl=en&answer=45656

    +(When I saved as a csv with Excel 2008 and opened the resulting file in a text editor, it was in fact a semicolon separated value file....I therefore had to substitute all semicolons for commas)+

    Directions to 2-way sync google calendars with ical and thunderbird:

    https://www.google.com/support/calendar/bin/answer.py?hl=en&answer=99358
  • Philip Raby1 Level 2 Level 2 (150 points)
    I've tried running the script but I'm getting errors, namely:

    error "Invalid date and time date Subject Start Date of «script»." number -30720

    Can someone advise on setting up the script? I suspect I'm not entering the date correctly (I assume I have to).

    Thanks

    Phil
  • Anthony.Carter Level 1 Level 1 (0 points)
    Hello. How does the .csv file need to be formatted? The scrip[t is not accepting mine as is.
  • Fred Davenport Level 1 Level 1 (0 points)
    Wow!

    Google does it again...

    Come on Apple, after many, many years of using iCal, I am very disppointed that this simple feature cannot happen..
  • jpsydney Level 1 Level 1 (0 points)
    Austin Kinsella1 thanks for your script. It works for me a bit, but not perfectly, can you advise? I have the csv as you sy, but the start and end times placed in ical are always 12:00 AM rather than what is in item 2 and item 3.

    Any help appreciated. Thanks, JP
  • Hebhebs Level 1 Level 1 (0 points)
    Hi,
    I am new to scripting, I was looking for a script to import csv files to ical and found this discussion.
    I tried you script in ASeditor and I keep getting:

    "Invalid date and time date date tart time of «script»"

    HELP!!
  • ryin13 Level 1 Level 1 (0 points)

    If you dont want to bother with the scripting -- you can just import the CSV into a google calendar and then export it back out as an ics, then you import that ics file into ical.

    Took me all of 5 minutes to do it.

     

    Here is how to import csv into google calendar:

    http://www.google.com/support/calendar/bin/answer.py?hl=en&answer=37118&topic=16 72003

     

    This is the google help file on getting your CSV formatted properly in case there is a problem:

    http://www.google.com/support/calendar/bin/answer.py?answer=45656

     

    Here is how to export out of google calendar:

    http://www.google.com/support/calendar/bin/answer.py?answer=37111

  • stephkr Level 1 Level 1 (0 points)

    Hi there everyone,

     

    I was wondering if this is now possible, since it has been a couple of years now?

     

    I work on a mac with a timeline of jobs in an excel sheet, however, I would love to be able to have the file sync automatically and update with my excel sheet as I add new jobs to the list...

     

    Is this a far fetched ambition?

Previous 1 2 Next