开发者

Load and read a csv file with php

I want to download some cont开发者_运维知识库ent in csv format. It is stored online in a csv file. I can not just read the content. I first have to download the file, open and then read it.

Is there a way to open it directly? Or do I have to first load/upload it on my server and then open it like a classic file?


Yes, it can open directly using fopen and fgetcsv

However, this feature sometime is restricted for security concern, and you can read the details via the documentation

  • http://php.net/manual/en/function.fopen.php
  • http://php.net/manual/en/function.fgetcsv.php

Another drawback of open directly, if the page is processed many time, which mean it generate lots of network transfer overhead, and potentially slow down your page generation time.

Ideal case will be download into your server, and repeated use local disk file for processing, that will save some network bandwidth.


Check out fgetcsv() and str_getcsv()

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜