Permalink
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
127 lines (117 sloc) 4.41 KB

HTML

|HtmlTableWriter| class can write a table to a stream with table tag format from a matrix of data.

Sample Code:
Output:
<table id="example_table">
    <caption>example_table</caption>
    <thead>
        <tr>
            <th>int</th>
            <th>float</th>
            <th>str</th>
            <th>bool</th>
            <th>mix</th>
            <th>time</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td align="right">0</td>
            <td align="right">0.10</td>
            <td align="left">hoge</td>
            <td align="left">True</td>
            <td align="right">0</td>
            <td align="left">2017-01-01 03:04:05+0900</td>
        </tr>
        <tr>
            <td align="right">2</td>
            <td align="right">-2.23</td>
            <td align="left">foo</td>
            <td align="left">False</td>
            <td align="left"></td>
            <td align="left">2017-12-23 12:34:51+0900</td>
        </tr>
        <tr>
            <td align="right">3</td>
            <td align="right">0.00</td>
            <td align="left">bar</td>
            <td align="left">True</td>
            <td align="left">Infinity</td>
            <td align="left">2017-03-03 22:44:55+0900</td>
        </tr>
        <tr>
            <td align="right">-10</td>
            <td align="right">-9.90</td>
            <td align="left"></td>
            <td align="left">False</td>
            <td align="left">NaN</td>
            <td align="left">2017-01-01 00:00:00+0900</td>
        </tr>
    </tbody>
</table>
Rendering Result:
example_table
int float str bool mix time
0 0.1 hoge True 0 2017-01-01 03:04:05+0900
2 -2.2 foo False 2017-12-23 12:34:51+0900
3 0.0 bar True inf 2017-03-03 22:44:55+0900
-10 -9.9 False nan 2017-01-01 00:00:00+0900