Python based web reporting tool? [closed] - python

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 months ago.
Improve this question
I have a question for those of you doing web work with python. Is
anyone familiar with a python based reporting tool? I am about to
start on a pretty big web app and will need the ability to do some end
user reporting (invoices, revenue reports, etc). It can be an existing
django app or anything python based so I can hook into it.

ReportLab
Welcome to the ReportLab Open Source site. ReportLab is a library for programatically creating PDF documents. It's a fast, flexible, cross platform solution written in Python.

Or go a little higher level than reportlab: xhtml2pdf - now WeasyPrint (built on top of reportlab)
From the website:
Translates HTML and CSS input into PDF files
Is written pure Python and therefore platform independent
Supports document specifics like columns, headers, footers, page numbers, custom Postscript and TrueType fonts, etc.
Best support for frameworks like Django, Turbogears, CherryPy, Pylons, WSGI
Simple integration into Python programms
Also available as stand alone command line tool for Windows, MacOS X and Linux

Most reporting tools are stuck in the '80s: a time when you 'painted' a report intended to be printed that completely lacked integration with other reports.
Sometimes we still need that. If you need to print an invoice, you're pretty much stuck with that kind of functionality. But in general, most reporting these days consists of multiple queries/charts/graphs/tables per page with drill-down built directly into it.
If you've got enough of a need go with an OLAP tool - then you don't even code the reports, your users (theoretically) can. If not, I've seldom seen a scenario in which a "reporting tool" was better than using something like Chart Director with a language like php, perl, python, ruby, etc.

Try to have look at the Cubes - Light-weight OLAP framework for Python. It is just partial solution for your problem, but I think it might help.
Sources at github
Documentation
Blog with tutorials
You can either use Python to do OLAP/aggregated browsing or you can run an OLAP HTTP Server (called Slicer). Here is an example using HTTP Server: Open Public Procurements reporting. The front-end is PHP which accesses Slicer server through HTTP. Example of server can be found here with documentation for the server can be found here.
Currently the framework provides SQL backend using SQLAlchemy, so you can use any DB that can SQLAlchemy has engine for.
Reports in form of charts, tables & stuff, including JS front-end framework are planned. Just wanted to help at least with lower OLAP layer.
Let me know if you have any questions, I am the author.

Also have a look at myDBR a tool that allows you to define your reports in the database (using stored procedures) and then takes care of the layout and formatting of the data.
Even though myDBR is a PHP application, it does not require any PHP coding, just install the application and embed it as iframe in your own app.

I've been working on a recent addition to this. It allows you to create HTML reports from Python which you can share as standalone HTML files. This means you can have interactive components - such as table viewers and interactive plots (which have become a lot more popular since this question was originally posed).
Currently it supports pandas DataFrames, Bokeh, Plotly, Altair, JSON, and Markdown components.
For instance:
import altair as alt
import pandas as pd
import datapane as dp
df = pd.read_csv('https://query1.finance.yahoo.com/v7/finance/download/GOOG?period1=1553600505&period2=1585222905&interval=1d&events=history')
chart = alt.Chart(df).encode(x='Date', y='High', y2='Low').mark_area(opacity=0.5).interactive()
dp.Report(dp.Table(df['High']), dp.Plot(chart)).save(path='stock_analysis.html')
It's still early, but check it out: https://docs.datapane.com

I was doing some research and found about awe. It runs a small webserver which can do realtime updates on a page and allows for more complicated report layouts.
It has documentation and examples and can give you something up and running, quickly.

Related

Running a Python Script on a Website (in the background)

Firstly, apologies for the very basic question. I have looked into other answers but they haven't quite answered what I'm after. I'm confident designing a site in HTML/CSS and have very very basic knowledge of Python.
I want to run a very basic Python script on my website. It analyses tweets about a specific topic, and then posts a sentiment analysis score. I want it to run this sentiment analysis every hour and cache the score.
I have a working Python script which does this in Jupyter Notebook. Could you give me an overview of how I would make this script function online and cache the results? I've read into using Python web frameworks, but from my limited understanding, they seem like overkill?
Thank you for your help!
Could you give me an overview of how I would make this script function online
The key thing would be to uncouple the two parts of your system:
Producing the data
Showing it in a website.
So the first thing to do is have your sentiment-analysis script push its value to a database. The database could be something as simple as a csv file, or it could be a key/value store, or something like MySQL or CouchDB (or hundreds of other choices).
Over on the website you have to make a decision between:
Server-side
Client-side
If the former, you could program in Python if that is what you are most familiar with. Whatever language/framework combination you go for, there will an example tutorial of how to read a value from a database and display it: it is just about the most fundamental thing.
If client-side you will usually be programming in JavaScript. Again you need to choose a framework, but again you should easily be able to find a tutorial to follow.
(Unless you have a good reason to prefer server-side, such as familiarity with an existing framework, or security issues with accessing your database, I'd go with a client-side approach.)
I've read into using Python web frameworks... overkill?
Yes and no. You are going to need some kind of database, and some kind of framework. It would be good to understand the basics of web security, too. If the sentiment analysis is your major goal, all that is going to be a distraction, and it might be better to find a friend who already knows web programming to work with. Or just find a tutorial that is very close to what you want to do, and adapt that.
(P.S. I was going to flag your question as "too broad", but you did ask for an overview, so I hope this helps.)

Can Django work well with pandas and numpy?

I am trying to build a web application that requires intensive mathematical calculations. Can I use Django to populate python charts and pandas dataframe?
You can use any framework to do so. If you worked with Python before I can recommend using Django since you have the same (clear Python) syntax along your project. This is good because you keep the same logic everywhere but should not be your major concern when it comes to choosing the right framework for your needs. So for example if you are a top Ruby-On-Rails developer I would not suggest to learn Django just because of Pandas.
In general: A lot of packages/libraries are written in other languages but you will still be able to use them in Django/Python. So for example the famous "Elasticsearch" Searchbackend has its roots in JAVA but is still used in a lot of Django apps.
But it also goes the other way around "Celery" is written in Python but can be used in Node.js or PHP. There are hundreds of examples but I think you get the Point.
I hope that I brought some light into the darkness. If you have questions please leave them in the comments.

Doubts about a Python Webserver

I've a project which I developed a code to capture a temperature in some sensors and displaying a temperature to people, in fact I've a database (txt archive) whose was readed in a webserver to people in same network, now I've to improve this webpage (with some graphics, analitycs and etc) .
Someone has a tip to improve that? or begin a new project with a better solution ?
For sure, if you are beginner in python then you should try do it as simple as it can be for example using Flask, all information you can find here: http://flask.pocoo.org/
Also if you want to write serious web page which contain advanced backend then you probably need Django: https://www.djangoproject.com/
EDIT:
I see that you already have some application that probably contain data from sensors, then it is good idea to re use it as a module for your web-service .

Use Python CGI or Django for a web project

I am a front-end web developer learning Python and decided to try to create a website for a friend. The website contains an astrology calculator that will generate a chart image and reading based on a person's birth date, birth time, and birthplace. I can use either Python CGI or Django to build this. Which one is appropriate for this project?
The chart calculator will:
1. generate an image of a chart with the correct houses and signs lined up.
2. plot the planets in the correct houses in the chart
3. show the connections between the stars, like a trine, square, or conjuction.
To render images, I think HTML5 can probably work. For the server-side scripting I am leaning towards CGI because it seems like you can write real Python programs with it and just output the results with something like print "sun conjunct jupiter". Django seems to limit you to that weird syntax that forces you to write every Python expression in these <% ... %> brackets and it doesn't seem like you can import Python modules easily.
I am not extremely familiar with Django, but these seem to be some of the limitations I noticed in the Django tutorial.
What do others in the community think? Should I use CGI or Django to create this website?
I checked out other questions, but not sure if a Python mini-framework is appropriate here.
Not really sure what you're hoping to glean from this (or what the question is exactly), but you seem to be misinterpreting what the Python CGI functions and Django are.
Django is a web framework meant to expedite the process of developing a website, so you can focus on specific issues (like the chart problem you described) rather than have to tend to the infrastructure of a site. It's meant to abstract away CGI (to oversimplify it a bit). If you're looking for something less heavy than Django, perhaps try Flask or Bottle.
PS: A quick Google search showed a similar question from a few years back: My first web app (Python): use CGI, or a framework like Django?

Charts in django Web Applications

I want to Embed a chart in a Web Application developed using django.
I have come across Google charts API, ReportLab, PyChart, MatPlotLib and ChartDirector
I want to do it in the server side rather than send the AJAX request to Google chart APIs, as I also want to embed the chart into the PDF.
Which is the best option to use, and what are the relative merits and demerits of one over the other.
Another choice is CairoPlot.
We picked matplotlib over the others for some serious graphing inside one of our django apps, primarily because it was the only one that gave us exactly the kind of control we needed.
Performance generating PNG's was fine for us but... it was a highly specialized app with less than 10 logins a day.
Well, I'm involved in an open source project, Djime, that uses OpenFlashChart 2.
As you can see from our code, generating the JSON-data that OFC uses is a bit complex, but the output is very nice and user friendly, since you can add tooltips, etc. to the different elements.
Open Flash Chart 2
http://teethgrinder.co.uk/open-flash-chart-2/
python library http://btbytes.github.com/pyofc2/
kybi
One package I've wanted to try is graphite. It's a graphing server / platform built with Django. It's specialized for "numeric time-series data" though, like stock prices or bandwidth utilization. If that fits your need I would check it out. Here are some screenshots:
http://graphite.wikidot.com/screen-shots
I like client side charts because you can get full page plotting.
A good options seems to be Jquery Flot : http://code.google.com/p/flot/ which can load JSON data.
However, you won't get pdf support.
Perhaps you might want to have a look here: Django Plotting app.
The HowTo describes how to embed matplotlib plots into the admin interface and create a PDF view.
I have used FusionCharts Free with Django.
Its flash based, open source, multi-licensed and it's well documented. It's ActionScript 1, but AS version wasn't really a criteria for me, though it could be for others.

Categories

Resources