I have come unstuck on a relatively (almost) trivial problem. I have a row of data that I want to display in tabular form (HTML). For some reason (possibly long day [again] behind the computer), I am not coming up with any elegant solutions (algorithms) to do this.
I have presented some sample data, and how such data would be displayed in the table. I would be grateful for some ideas on algos to implement this.
The output table has rows labelled with the various scores and the indices are displayed at the bottom.
I would like to be able to have a variable determine the number of columns to print, before a new table is printed underneath - to prevent ridiculously long tables.
so I want to write a function with the following signature (ignoring data types):
function create_table_html_from_rows(datarows, max_cols_per_table)
Here is the sample data and mock output table presentation
Row data:
index, Score, amount
1, level 1, 12.24
3, level 4, 14.61
9, level 10, 42.35
15, level 2, -8.12
Scores
======
Level 1 12.24
Level 2 -8.12
Level 3
Level 4 14.61
.....
Level 10 42.35
----------------------------------------
| 1 | 3 | 9 | 15 <- Index
Pseudocode should be sufficient, however, if you snippet is in a programming language, it is perharps worth pointing out that I will be implementing my algorithm in Python, however any snippets in any of the following languages would be fine:
Python, C, C++, PHP, C#