user2880845
user2880845

Reputation: 39

Code Logic to display .csv file on a browser

my project has me needing to read a csv file and display in a browser automatically. Before I post the code, I want to confirm I have the logic correct and not be confusing myself with more development then necessary. From my research there is 2 ways this can be done at a bare basic level.

Cross domain: A program (R) on server 1 has outputted a csv file on some set time interval. I then need to use a server side language (php) on server 1 to parse the data and put into an array. I then use a php proxy or JSONP format on server 2 for a cross domain GET to call it via AJAX and load into the client side script on server 2.

Same domain: A program (R) on the server has outputted a csv file on some set time interval. I would still need to use a php script to parse the data and put data into an array, which then I do an AJAX call to load the data into the client side script in JS.

I cannot use jquery-csv plugin and HTML5 FileReader to do so automatically in either case because that is for a client user manually uploading a file?

Also, to have a 2 way connection whereby data is push and pull I need to implement websockets or long polling/HTTP streaming.

Please confirm my logic above.

Thanks.

Upvotes: 0

Views: 203

Answers (1)

Dmitriy Mozgovoy
Dmitriy Mozgovoy

Reputation: 46

You need to parse CSV on the first server and send parsed data to server 1 (or download to server 1 from server 2)? If so, you just need fgetcsv on server 1 and simple curl/file_read_contents on server 2.

Upvotes: 1

Related Questions