CSV to html

ਜਾਣਕਾਰੀ

CSV to html makes it easy to fetch content from csv-file(s) and put content from that file/those files and display the html(table) on a page with a single shortcode.

If you created files to use with the Visualizer Plugin, those are formatted in a specific way and if you have saved the csv-file(s) from excel, the csv looks
different. CSV to html handles both these types and it’s fairly easy to extend the plugin to use other mechanisms to identify a specific type of format of the csv-file(s).

If using more then one file, content from all files are mixed into one single table – rather then creating two tables. It’s possible to fetch information from csv files from webservers upload folder (or a subfolder to the uploadsfolder) or
from an external source (domain).

If you like the plugin, please consider donating.

Example of usage

shortcodes in post(s)/page(s)

  • [csvtohtml_create source_type=”visualizer_plugin” path=”lan” source_files=”skane.csv;smaland.csv;lappland.csv”]
  • [csvtohtml_create source_type=”guess” path=”excelfolder” source_files=”excel1.csv;excel2.csv”]
  • [csvtohtml_create source_type=”guess” path=”excelfolder” source_files=”*.csv”]
  • [csvtohtml_create source_type=”guess” path=”excelfolder” source_files=”excel1;excel2″ debug_mode=”yes”]
  • [csvtohtml_create source_type=”guess” path=”excelfolder” source_files=”excel1.csv;excel2.csv” debug_mode=”yes” fetch_lastheaders=”3″]
  • [csvtohtml_create source_type=”guess” path=”excelfolder” source_files=”excel1;excel2;http://wibergsweb.se/map/sweden.csv” debug_mode=”yes”]
  • [csvtohtml_create source_type=”guess” path=”excelfolder” source_files=”excel1;excel2;http://wibergsweb.se/map/sweden.csv” include_cols=”5,6,7,12-14″ eol_detection=”auto” debug_mode=”yes”]
  • [csvtohtml_create source_type=”guess” path=”excelfolder” source_files=”excel1;excel2;http://wibergsweb.se/map/sweden.csv” exclude_cols=”3″ debug_mode=”yes” eol_detection=”CR/LF”]
  • [csvtohtml_create html_class=”tablesorter” source_type=”guess” path=”excelfolder” source_files=”excel1;excel2;http://wibergsweb.se/map/sweden.csv” exclude_cols=”3,7,9,11-13″]
  • [csvtohtml_create source_type=”guess” path=”excelfolder” source_files=”whatever.csv” csv_delimiter=”;”]
  • [csvtohtml_create source_type=”guess” source_files=”http://wibergsweb.se/map/sweden.csv” debug_mode=”no” convert_encoding_from=”Windows-1252″ convert_encoding_to=”UTF-8″]
  • [csvtohtml_create source_type=”guess” source_files=”http://wibergsweb.se/map/sweden.csv” debug_mode=”no” convert_encoding_to=”UTF-8″]
  • [csvtohtml_create source_type=”guess” source_files=”http://wibergsweb.se/map/sweden.csv” debug_mode=”no” sort_cols=”1,2″ sort_cols_order=”desc,asc”]

Example css

  • .csvtohtml th.colset-1 {background:#ff0000 !important;}
  • .csvtohtml .even{background:#ddd;}

You can find demos at: http://wibergsweb.se/plugins/csvtohtml/

ਸਕਰੀਨਸ਼ਾਟ

  • Screenshot - using format of visualizer pluginfiles
  • Screenshot - why does not iceland show?
  • Screenshot - iceland.csv file didn't exist, now it does
  • Screenshot - show title in top left corner
  • Screenshot - Some css applied.
  • Screenshot - fetch only three last headers

ਸਥਾਪਤੀਕਰਨ

This section describes how to install the plugin and get it working.

  1. Upload the plugin folder csvtohtml to the `/wp-content/plugins/’ directory, or install the plugin through the WordPress plugins screen directly.
  2. Activate the plugin through the ‘Plugins’ screen in WordPress
  3. Put shortcode on the WordPress post or page you want to display it on and add css to change layout for those.

Shortcodes

  • [csvtohtml_create] – Create the html table from specified csv-file(s)

[csvtohtml_create] attributes

  • title – set title that is shown as text in top left corner of html table (else nothing is shown there)
  • html_id – set id of this table
  • html_class – set class of this table (besides default csvtohtml – class)
  • path – relative path to uploads-folder of the wordpress – installation ( eg. /wp-content/uploads/{path} )
  • source_type – what type to use for identifying content in csv-files (valid types are guess and visualizer_plugin).
  • fetch_lastheaders – Number of specific headers to retrieve (from end)
  • source_files – file(s) to include. If using more than one file – separate them with a semicolon (;). It ‘s (from v1.0.2) possible to include a full url instead of a filename to fetch external csv files. It’s also possible (v1.1.36) to fetch files from a given path (with for example *.csv).
  • csv_delimiter – what delimiter to use in each line of csv (comma, semicolon etc)
  • exclude_cols – What columns to exclude in final html table (1,2,3,10-15 would exclude columns 1,2,3,10,11,12,13,14 and 15). If you want to remove the last column, then simply type last instead of entering a number.
  • include_cols – What columns to include in final html table (1,2,3,10-15 would display column 1,2,3,10,11,12,13,14 and 15). If include_cols is given, then exclude_cols is ignored.
  • eol_detection – CR = Carriage return, LF = Line feed, CR/LF = Carriage line and line feed, auto = autodetect. Only useful on external files. Other files are automatically autodeteced.
  • convert_encoding_from – When converting character encoding, define what current characterencoding that csv file has. (Not required, but gives best result)
  • convert_encoding_to – When converting character encoding, define what characterencoding that csv should be encoded to. (Best result of encoding is when you define both encoding from and encoding both)
  • sort_cols – Which column(s) to sort on in format nr,nr och nr-nr (example 1,2,4 or 1-2,4)
  • sort_cols_order – Which order to sort columns on (asc/desc). If you have 3 columns, you can define these with different sorting like asc,desc,asc
  • add_ext_auto – Add fileextension .csv to file (if it’s not specified in the source_files). Set to no if you don’t file extension to be added automatically.
  • debug_mode – if set to yes then header-values and row-values would be output to screen and files like “file not found” will be displayed (otherwise it would be “silent errors”)

Default values

  • [csvtohtml_create title=”{none}” html_id=”{none}” html_class=”{none}” source_type=”visualizer_plugin” path=”{none}” fetch_lastheaders=”0″ source_files=”{none}” csv_delimiter=”,” exclude_cols=”{none} include_cols=”{none}” eol_detection=”cr/lf” convert_encoding_from=”{none}” convert_encoding_to=”{to}” sort_cols=”{none}” sort_cols_order=”asc” add_ext_auto=”yes” debug_mode=”no”]

ਸਵਾਲ-ਜਵਾਬ

Why don’t you include any css for the plugin?

The goal is to make the plugin work as fast as possible as expected even with the design. By not supplying any css the developer has full control over
the design.

ਸਮੀਖਿਆਵਾਂ

1 ਮਈ 2019
It is very simple but very useful. I looked plug-in for to add live chart table in my homepage without using programming. Upload a CSV file to an appropriate place and just link to, it was possible to see the auto-refresh table data in my site by click the refresh button. I'm very satisfied with a very simple use and a feature that is not found in other table-related plug-ins.
20 ਨਵੰਬਰ 2018
Developer was more than willing to help and even added a "missing" feature in a couple of days. Highly recommended!
3 ਸਤੰਬਰ 2016
Very satisfied - the author replies quickly with solutions. He was able to integrate a new feature I had recommended in a very short time. Incredible! 5/5 stars.
Read all 6 reviews

ਯੋਗਦਾਨੀ ਤੇ ਵਿਕਾਸਕਾਰ

“CSV to html” is open source software. The following people have contributed to this plugin.

ਯੋਗਦਾਨੀ

ਤਬਦੀਲੀ-ਚਿੱਠਾ

1.1.44

  • A new attribute has been added so .csv does not have to be added automatically. This could be useful when loading files from Google Drive or similar cloud based services.

1.1.43

  • A html-tag that (for some reason) has been inserted by mistake. It’s now corrected. Validation of html table should now validate.

1.1.42

  • Some missing tag in table corrected (/tbody and id-attribute(when used) corrected).

1.1.41

  • Debug code removed. (update to this version if you tried to install/update to 1.1.40!)

1.1.40

  • Changed autodetection of EOL to auto(detect) (from cr/lf) when importing CSV-files.

1.1.39

  • Bugfix: Display order of columns when including, excluding is fixed. (In some circumstances the display order of columns would be inccorect before)

1.1.38

  • CURL is not used anymore for fetching external files. Instead native WordPress HTTP API is used. Why? It’s faster and handles security (with ssl) much better. As a fallback CURL is used by the HTTP API.

1.1.37

  • Bugfix admin page. Important to update to this version! (if you have installed 1.1.36)

1.1.36

  • Help-page introduced in wordpress dashboard
  • Debugging functionality improved
  • CURL bugfix when mixing http and https – protocols.
  • Possible to disable/ignore curl if something goes wrong (even if CURL is installed)
  • Now it’s possible to use wildcards (to grab all csv-file from a specified path for example)

1.1.31

  • Bugfix sorting on columns when both asc and desc are used

1.1.3

  • Sorting of columns are now possible. It’s also possible to define different sortorders depending on which column is sorted.

1.1.1

  • Now it’s possible to convert(translate) characterencoding from csv to another charset (for display)

1.0.9

  • Now it’s possible to use “last” instead of entering a specifing column-number when excluding a column.

1.0.8

  • Now it’s possible to use a custom delimiter for each row in a csv file.

1.0.7

  • Autodetection of line endings now supported. Works automatically on local files (on server)
  • Possible to specifiy custom line endings when loading external links (when CURL is enabled)

1.0.5

  • Now it’s possible to specify an extra class for the table. Example: If used together with the tablesorter plugin (https://wordpress.org/plugins/table-sorter/) you can add a class called tablesorter and combine these two plugins to
    create a “tablesorted” html table generated from csv file(s) in realtime.

1.0.4

  • Now it’s possible to include or exclude columns in format 1,2,3 or 1-3. It’s also possible to combine these two eg. 1,2,3,7-9,13,14,15.

1.0.2

  • Semantic bugfix. When not defining a path an extra slash was included in the path. Now there are no extra slashes.
  • Now it’s possible to include a full url to fetch csv-files from external sources. CURL are used to fetch csv files from external sources, but if CURL is not installed, then php’s file() function is used but that requires that the server
    has allow url fopen enabled.

1.0

  • Plugin released