简体   繁体   English

使用脚本导出和导入.csv文件

[英]Exporting and Importing .csv files using a script

Hi I have a MAMP server set up on a mac I am using and I have this displaying a calendar using the php icalendar source code. 嗨,我在正在使用的Mac上设置了MAMP服务器,并使用php icalendar源代码显示了日历。 I am trying to have this display a public calendar which I can do but I need it to be up to date so I need it to import the Calendars csv file regularly. 我正在尝试让该显示器显示公共日历,但是我需要将其更新为最新状态,因此需要定期导入Calendar csv文件。 So my question is does anyone know how I could go about programmatically exporting a .csv file from a public calendar and how I could then import it into a certain location on a server again via a script or code? 所以我的问题是,有谁知道我该如何以编程方式从公共日历中导出.csv文件,然后又如何通过脚本或代码将其导入服务器上的某个位置?

Thanks a lot 非常感谢

There are a lot of ways to download the .csv file. 有很多方法可以下载.csv文件。

You could use fopen, cURL to download the file. 您可以使用fopen,cURL来下载文件。 For fopen you need to enable to read files from an url. 对于fopen,您需要启用从URL读取文件的功能。

An other way, must be supported by the other party. 另一种方式,必须得到另一方的支持。 Is to use ftp. 是用ftp。

I think the best way for these is just look at php.net how to let them work. 我认为最好的方法是查看php.net,如何使它们工作。

Second you want to make a scheduld job. 第二,你想做一份预定的工作。 I don't know it in macs, but with linux you can make cron's you can say these need to be run every x time (1min, 1day 1 week). 我在macs中不知道,但是使用linux可以将cron转换为cron,可以说这些需要每x次(1分钟,1天1周)运行一次。

In the script you do the download and update part. 在脚本中,执行下载和更新部分。

Hope it helps 希望能帮助到你

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM