将CSV文件导入iCal

将CSV文件导入iCal,csv,applescript,icalendar,Csv,Applescript,Icalendar,我在word文档表中得到了我的教学计划和学期计划。我想知道是否有办法将这些数据输入iCal。在iCal中创建事件比将这些表复制到excel文件并从中导入iCal所需的时间要长得多 数据将是一天的活动,即2013年2月22日的家庭聚会,其余数据将是2周或3周的活动,即3周-Gr.10数学-主题:指数(这些活动将是5天的活动(周一至周五),重复3周。) 这是我从互联网上得到的一个脚本——但它给我的第一个错误是它无法将.csv文件文本转换为Unicode类型 脚本后面的另一个问题是让这5天的活动重复3

我在word文档表中得到了我的教学计划和学期计划。我想知道是否有办法将这些数据输入iCal。在iCal中创建事件比将这些表复制到excel文件并从中导入iCal所需的时间要长得多

数据将是一天的活动,即2013年2月22日的家庭聚会,其余数据将是2周或3周的活动,即3周-Gr.10数学-主题:指数(这些活动将是5天的活动(周一至周五),重复3周。)

这是我从互联网上得到的一个脚本——但它给我的第一个错误是它无法将.csv文件文本转换为Unicode类型

脚本后面的另一个问题是让这5天的活动重复3到2周

任何帮助都将不胜感激。这就是我迄今为止所做的:

  --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 "Calendar"
            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
好的,谢谢你的回复,这是我到目前为止所做的,我无法获得重复次数,以使用NumberCount作为事件重复次数的计数:

set text item delimiters to ";"
repeat with l in paragraphs of (read "/Users/pienaar0/Desktop/test.csv" as «class utf8»)
if contents of l is not "" then
    set sd to date (text item 1 of l & " ")
    set ed to date (text item 2 of l & " ")
    set NumberWeeks to (text item 4 of l & " ")
    set NumberCount to NumberWeeks - 1
    tell application "Calendar" to tell calendar "Test"
        make new event with properties {allday event:true, start date:sd, end date:ed, summary:text item 3 of l, recurrence:"FREQ=WEEKLY;COUNT=2 * NumberCount"}

    end tell
end if
 end repeat
test.csv:

01/25/2013,10:30PM,11:00PM,test event
01/26/2013,00:00AM,01:00AM,test event2

试着解决这个问题:“我把我的教学计划和学期计划放在word文档表中。”(无意冒犯!)我不明白你的意思?这就是我得到它的方式,我不介意手动将它输入到.csv格式谢谢你的回复,我仍然得到这个错误:?error“无法将\”01/25/2012的每个段落的第1项中的第2项变成文本;晚上十时三十分;晚上十一时;测试事件2012年1月26日;00:00;凌晨1时;测试事件2 \“输入Unicode文本。”编号-1700,从“2012年1月25日;10:30pm;11:00pm;测试事件2012年1月26日;00:00am;01:00am;测试事件2”的每个段落的项目1的文本项目2到Unicode文本可能与Excel中的csv文件有关?或者工作表中数据的格式?只需在开始时将文本项分隔符更改为“
”;“
”。我如何使其适用于超过一天的事件,然后使其在一段时间内重复?
01/25/2013,10:30PM,11:00PM,test event
01/26/2013,00:00AM,01:00AM,test event2