我需要自动将iCalendar日历从iCal(显然在Mac上)导出到.ics文件。我知道我可以通过File-> Export在iCal中手动执行此操作。我从共享日历中提取数据,以便在MATLAB中进行分析。然后,我想使用cron
经常提取数据进行分析。
或者,如果有人知道日历数据存储在本地的位置,那么我想我应该能够为事件/数据解析该文件。
答案 0 :(得分:0)
可能没有matlab实现,至少matlab文件交换列表没什么。要将日历数据导入Matlab,我会使用像iCal4j这样的Java库。您可以调用java库directly in m code。
还可以在Matlab中访问C,C ++,dll和.Net。在我看来,java桥是最简单的使用,这就是我建议使用java解决方案的原因。
答案 1 :(得分:0)
数据目录是〜/ Library / Calendars / [account] / [calendar] 每个子目录的名称是UID。每个子目录都包含一个文件“info.plist”:
帐户:
import java.util.ArrayList;
public class Donation {
protected static ArrayList<Runner> Runners = new ArrayList<Runner>();
public Donation(ArrayList<Runner> runners){
for(int i = 0; i < runners.size(); i++){
Runners.add(runners.get(i));
}
mergeSort(Runners, 0,Runners.size()-1);
}
public void addRunner(String n, String id, double r){
Runners.add(new Runner(n, id, r));
}
public String displayInfo(int index){
String str = Runners.get(index).toString();
return str;
}
public void addDonations(int index, double amt){
Runners.get(index).Raised+=amt;
}
public double getSum(){
double sum=0;
for(int i = 0; i < Runners.size(); i++){
sum+=Runners.get(i).Raised;
}
return sum;
}
public ArrayList<Runner> getRunnerObj(){
return Runners;
}
public String goldenSneaker(){
String gold = "";
return gold;
}
public String silverSneaker(){
String silver = "";
return silver;
}
public String bronzeSneaker(){
String bronze = "";
return bronze;
}
public String achillesHeel(){
String ach = "";
return ach;
}
public void writeToFile(){
}
public static void mergeSort(ArrayList<Runner> runners, int min, int max){
if(min < max){
int mid = (min+max)/2;
mergeSort(runners, min, mid);
mergeSort(runners, mid+1, max);
merge2(runners, min, mid, max);
}
}
public static void merge2(ArrayList<Runner> runners, int first, int mid, int last){
ArrayList<Runner> temp = new ArrayList<>();
int f1 = first;
int l1 = mid;
int f2 = mid+1;
int l2 = last;
int index = 0;
for(int i = first; i <=last; i++){
temp.add(runners.get(i));
}
while(f1 <= l1 && f2 <= l2){
if(runners.get(f1).getRaised() < runners.get(f2).getRaised()){
temp.set(index, runners.get(f1));
f1++;
}else{
temp.set(index, runners.get(f2));
f2++;
}
index++;
}
while(f1 <= l1){
temp.set(index, runners.get(f1));
f1++;
index++;
}
while(f2<=l2){
temp.set(index, runners.get(f2));
f2++;
index++;
}
index = 0;
for(int i = first; i<=last;i++){
runners.set(i,temp.get(index));
index++;
}
}
}
日历:
...
<key>Key</key>
<string>[UID]</string>
<key>Login</key>
<string>[account, i.e. mail address]</string>
事件存储在“Events”子目录中(每个事件的1个.ics文件)