We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 34162
    • 1 Posts
    This is an auto-generated topic for <a href="http://modxcms.com/extras/package/576">cvs2table 0.1-rc1</a> by chrisdpratt.

    Brief Description:
    Snippet that converts a CSV file to an HTML table.
      • 302
      • 6 Posts
      Nice one... this snippet is exactly what I need for a stats site I am working on... however I need some help getting it to build the table properly.

      I am using a .csv file saved from a Microsoft Excel spreadsheet.

      Calling the snippet produces a table with one row and all the elements from the spreadsheet in either <th> or <td> tags?? I have figured out that adding &hasRowHeader and &hasColHeader changes that. But it doesn’t seem to recognizing the rows in excel.

      Am I missing something in the snippet call? When I added delimiters and enclosures they went to their defaults but didn’t affect the table structure. Is this an excel spreadsheet issue? Does the snippet support template chunks the same way Ditto or wayfinder does???

      <table border="0">
      [[csv2table? &amp;hasColHeader=`0` &amp;hasRowHeader=`1` &amp;csv=`(.csv file)`]]
      </table>

      Please HELP!
      Dave
        • 27352
        • 9 Posts
        Search not working...

        Work with another charset not working, but we make small change:


        if ($count_space == (count($row) -1) ) {
        $header = $res = iconv(’Windows-1251’, ’UTF-8’, $row[0]);
        $output .= ’<tr><td colspan=’. count($row) .’><h2>’ . $header .’</h2></td></tr>’;
        continue;
        }

        if (($k == 0) && $this->params[’hasRowHeader’]) {
        $output .= ’ <th>’.$v.’</th>’."\n";
        } else {
        $res = iconv(’Windows-1251’, ’UTF-8’, $v);
        $output .= ’ <td>’. $res . ’ </td>’."\n";
        }