CSV to html – external files

External files

With CSV to HTML it is also possible to fetch data from external files (the files does not have to be on your own server). Down below is actually a mix of an external file (https – sweden) and internal files (norway,finland,iceland,denmark):

Shortcode
[csvtohtml_create
title="Nordic stats"
source_type="visualizer_plugin"
path="csvfiles" //This path is only used for local files (files on the webserver where you run this plugin)
source_files="https://wibergsweb.se/wp-content/uploads/csvfiles/sweden.csv;norway;finland;iceland;denmark"]
20112012201320142015
Sweden1.6%2.2%3.2%4.5%6.9%
Norway-6.6%1.2%1.4%1.9%2.0%
Finland-16.6%-14.2%10.2%11.0%13.2%
Iceland6.6%6.2%7.2%11.0%16.2%
Denmark-2.6%0%2.6%2.9%2.11%

It’s also possible to fetch google sheets if adding some attributes to the url and setting an attribute for the shortcode (add_ext_auto). This add_ext_auto adds the file extension .csv as default. When dealing with google sheets (or maybe some other source) you don’t want any file extension to be added.

Shortcode
[csvtohtml_create
title="Nordic stats"
source_type="guess"
add_ext_auto = "no"
source_files="https://docs.google.com/spreadsheets/d/{key}/gviz/tq?tqx=out:csv&sheet={sheet_name}"]

There are no preview for this because google sheet’s specification how to achieve this usually do change over time. Please take a look at https://stackoverflow.com/questions/33713084/download-link-for-google-spreadsheets-csv-export-with-multiple-sheets for some ideas how to fetch your google sheets document as a csv file.