473,378 Members | 1,417 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

how to generate html table from "table" data?


Hi group,
I would like to convert the output of the SQL query, or more generally
I would like to convert any "table" data to the html table.

I would like to set some rules to format cells, columns or rows (font,
colour etc.) of the html table, according to the values in the
specific cells.

Googling for a while I have found only this tool:
http://pasko.net/PyHtmlTable/

Your tips to some other tools or/and your suggestion how to solve
above mentioned will be very helpful.

Thanks and regards

Petr Jakes
Dec 25 '07 #1
7 3704
pe************@gmail.com a écrit :
Hi group,
I would like to convert the output of the SQL query, or more generally
I would like to convert any "table" data to the html table.
There's MoreThanOneWayToDoIt... from simple string formatting to a
full-blown template engine.
I would like to set some rules to format cells, columns or rows (font,
colour etc.) of the html table, according to the values in the
specific cells.
<ot>
Markup should only convey semantic informations - presentation is best
done using css. IOW : presentation-related stuff in the html should be
restricted to css class declarations.
</ot>
Googling for a while I have found only this tool:
http://pasko.net/PyHtmlTable/

Your tips to some other tools or/and your suggestion how to solve
above mentioned will be very helpful.
As I said, wrt/ html generation, there are quite a lot of possible
solutions - FWIW, generating an html table from a set of tabular data is
nothing difficult. So without more information on the context, it's hard
to give any valuable advice. Are you doing a web application ? If yes,
you should already use a template engine, so just use it. Else, why is
your application generating html at all ?
Dec 26 '07 #2
petr.jakes....@gmail.com a écrit :
>
Hi group,
I would like to convert the output of the SQL query, or more generally
I would like to convert any "table" data to the html table.
I would like to set some rules to format cells, columns or rows (font,
colour etc.) of the html table, according to the values in the
specific cells.
Why not try writing your own code for this first?
If nothing else, it'll help you learn more, and may also help you
understand better, the other options.

Vasudev Ram
-----------
Dancing Bison Enterprises
Software consulting and training
Biz site: http://www.dancingbison.com
Blog (on software innovation): http://jugad.livejournal.com
Quick and easy PDF creation toolkit: http://www.dancingbison.com/products.html

Dec 26 '07 #3
>
Why not try writing your own code for this first?
If nothing else, it'll help you learn more, and may also help you
understand better, the other options.

Vasudev Ram
Thanks for your reply even it was not really helpful.
Of course some attempts to generate html from tabular data are behind
me. I am trying to find help here, because I think I am not the first
one, who is trying to "generate" html tables.

The purpose of my effort is to automatically and repeatedly read ¦QL
table and save the output of the SQL SELECT to the file in the html
format. Such a "reports" can be read by user using web browser later
on.

I was just trying to find if somebody here can point me to the
existing tool, which is suitable for such a task.

Anyway thank you for trying me help.

Petr Jakes
Dec 26 '07 #4
pe************@gmail.com a écrit :
Vasudev Ram wrote:
>>Why not try writing your own code for this first?
If nothing else, it'll help you learn more, and may also help you
understand better, the other options.

Thanks for your reply even it was not really helpful.
The answers boil down to:
- use the templating engine that comes with your web framework
or
- use whatever templating engine you like
or
- just do it by hand

The remaining work is obviously such a no-brainer that there's no need
for a specific package, and so application specific that there's
probably nothing like a one-size-fits-all answer. IOW : you're not
likely to find more "helpful" answer - and your above comment won't
help. FWIW, I just wrote a function generating an html table from a list
of header and a list of rows. I wrote the most Q&D, straightforward,
braindead way, it's 17 lines long, doesn't even need an import
statement, and took me less than 2 minutes to write - that is, far less
work than reading your post and answering it.
Dec 26 '07 #5
Dennis,
Thank you very much for your code snippet.
I will try to install CherryTemplate and use it.

I did not work with any template tool before and I am not the *****
class programmer as other people here, so my questions maybe look
"strange" or "stup..".

I didn't mean to offend somebody here and I am really grateful for all
replies.

Thank you

Petr Jakes
Dec 26 '07 #6
Bruno Desthuilliers wrote:
pe************@gmail.com a écrit :
Vasudev Ram wrote:
>>Why not try writing your own code for this first?
If nothing else, it'll help you learn more, and may also help you
understand better, the other options.
Thanks for your reply even it was not really helpful.

The answers boil down to:
- use the templating engine that comes with your web framework
or
- use whatever templating engine you like
or
- just do it by hand

The remaining work is obviously such a no-brainer that there's no need
for a specific package, and so application specific that there's
probably nothing like a one-size-fits-all answer. IOW : you're not
likely to find more "helpful" answer - and your above comment won't
help. FWIW, I just wrote a function generating an html table from a list
of header and a list of rows. I wrote the most Q&D, straightforward,
braindead way, it's 17 lines long, doesn't even need an import
statement, and took me less than 2 minutes to write - that is, far less
work than reading your post and answering it.
Hi.
Bruno, could you please post those 17 lines? I'm not actually doing HTML
work but I would find it interesting going through your code.

TIA

Dec 27 '07 #7
Ricardo Aráoz a écrit :
Bruno Desthuilliers wrote:
(snip)
>FWIW, I just wrote a function generating an html table from a list
of header and a list of rows. I wrote the most Q&D, straightforward,
braindead way, it's 17 lines long, doesn't even need an import
statement, and took me less than 2 minutes to write - that is, far less
work than reading your post and answering it.

Hi.
Bruno, could you please post those 17 lines? I'm not actually doing HTML
work but I would find it interesting going through your code.
I'm afraid I throw that code away - as I said, this was braindead Q&D
code, and certainly not even worth the time you'd spend reading it. But
I can rewrite it if you want:

def generate_html_table(headers, rows):
html = []

if headers:
html.append("<tr>")
for header in headers:
html.append("<th>%s</th>" % header)
html.append("</tr>")

if rows:
for row in rows:
html.append("<tr>")
for cell in row:
html.append("<td>%s</td>" % cell)
html.append("</tr>")

if html:
html = ["<table>"] + html + ["</table>"]

return "\n".join(html)
Nothing interesting here, as you can see. And if you're going to do
anything serious in web development, you'll be better using a templating
system anyway.
Dec 28 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Sugapablo | last post by:
Before I go building this, I want to know if it already exists. I need some PHP code that will read a web page and return all text that comes between <td></td> tags in an array. So if there...
11
by: alex | last post by:
Hi, I am looking for a way to populate an HTML table from an external local text file which looks like this: DATE/TIME LAT. LON. DEPTH. ML....
3
by: Sandros | last post by:
Background: I'm collecting usability statistics for a group of applications. Each count has the following attributes: date, application, major heading, minor heading, count. My intent is to pull...
10
by: john T | last post by:
Is there anyway to vertically center a html table using css in such a way it does not alter the html table. When I tryied it just screws up.
4
by: cardinallijr | last post by:
Hi all, sorry about the simple question but I'm new to XSL. I have a XML with 5 elements, for example: <root> <products> <product> <id>1</id> </product> <product>
0
by: Kamal Ahmed | last post by:
Hi All, I am using Asp.Net 1.1 inline coding with MS SQL Server as a backend for developing a solution. My requirement is to generate HTML Table as a cross tab to display columns an Rows and to...
4
by: McGowan | last post by:
Hi, I'm trying to display data from a mysql database in a HTML table but for some reason my code isn't working. At the moment I have got it to read and display the headers and the first row of the...
2
ramprabu
by: ramprabu | last post by:
Hello, I will give the sample code of html. Here first table only apply border 1 width. other tables are border 0. The problem is border=0 means border was not visible but it takes white border...
2
by: susinthaa | last post by:
Hi All, Good Morning! My requirement is as below: I am having a HTML table and the text boxes are embedded as a row of the tabel. And I am having a button at the end of the page. When I...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.