CSV to html

Description

CSV to html makes it easy to fetch content from a csv-file and put content from that file 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 both 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=”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=”;”]

Example css

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

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

Screenshots

  • 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

Installation

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.
  • 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)
  • 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 using CURL. Other files are automatically autodeteced.
  • 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=”guess” path=”{none}” fetch_lastheaders=”0″ source_files=”{none}” csv_delimiter=”,” exclude_cols=”{none} include_cols=”{none}” eol_detection=”cr/lf” debug_mode=”no”]

FAQ

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.

Reviews

Great plugin, excellent service

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 4 reviews

Contributors & Developers

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

Contributors

Translate “CSV to html” into your language.

Interested in development?

Browse the code, check out the SVN repository, or subscribe to the development log by RSS.

Changelog

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