DarkLeafyGreen
DarkLeafyGreen

Reputation: 70466

Load and read a csv file with php

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.

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?

Upvotes: 2

Views: 15476

Answers (2)

Jason McCreary
Jason McCreary

Reputation: 73031

Check out fgetcsv() and str_getcsv()

Upvotes: 1

ajreal
ajreal

Reputation: 47331

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

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.

Upvotes: 8

Related Questions