• cwcrogan

    (@cwcrogan)


    Hello, I’m trying to find a way (or a plugin) that will convert csv data from a custom field into a table. I have hundreds of posts using two custom fields containing simple (two column) csv data that is converted into a table using a plugin called EasyTable. Works perfectly, but I just learned that a) the plugin hasn’t been maintained in a number of years, and b) there may be a security issue using it. So I’m looking for an alternative but every plugin I’ve examined will only import csv from a file. Is there a simple way to accomplish this? TIA

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    You could likely modify one of those plugins to parse a custom field string instead of parsing a file stream. Plugins likely use fgetcsv(). Replace this with str_getcsv() and pass the custom field value instead of a file pointer. Further modification will be needed, such as removing the file open and close code, but that’s likely the gist of it. If you modify a plugin’s source code, please also give it a new name.

    Or you could create your own custom plugin from scratch. Get the custom field and run it through str_getcsv(), which results in an array of data. Loop through the array using element values to construct table elements. The entire output could be implemented through a shortcode. Where ever you want a table to appear in content, you could simply insert “[tablecsv]”.

Viewing 1 replies (of 1 total)
  • The topic ‘Create table from csv data in a custom field’ is closed to new replies.