Load and read a csv file with php

后端 未结 2 1570
小蘑菇
小蘑菇 2020-12-10 21:43

I want to download some content 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.<

相关标签:
2条回答
  • 2020-12-10 22:11

    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.

    0 讨论(0)
  • 2020-12-10 22:30

    Check out fgetcsv() and str_getcsv()

    0 讨论(0)
提交回复
热议问题