简体   繁体   English

使用格式构建报告

[英]Building a report with formatting

I am utilizing a background server connected to a GUI Flask application (both coded in python) to serve up report based information.我正在利用连接到 GUI Flask 应用程序(均用 python 编码)的后台服务器来提供基于报告的信息。 My report will have rows of information with columns of years.我的报告将包含带有年份列的信息行。

I would like to keep the GUI as independent of the background reports as possible, to keep the report development burden on the server.我希望 GUI 尽可能独立于背景报告,以减轻服务器的报告开发负担。

The problem I am faced with is how to incorporate the format of the information in the report rows so that the GUI can represent the information appropriately.我面临的问题是如何将信息的格式合并到报告行中,以便 GUI 可以适当地表示信息。 I share a report example below:我在下面分享一个报告示例:

          2020     2019     2018
Sales   $1,000   $1,300   $1,052
Growth    -23%      24%       --

Passing the data to the GUI would be managed with a dataframe / pysql process.将数据传递到 GUI 将通过 dataframe / pysql 进程进行管理。 Flask will of course be utilizing an html format. Flask 当然会使用 html 格式。 If the format was confined to the columns, I could use dataframe formatting to codify, but the variant display formats are occurring in the rows.如果格式仅限于列,我可以使用 dataframe 格式进行编码,但变体显示格式出现在行中。

I will be grateful for any thoughts on how I might approach this.对于如何处理此问题的任何想法,我将不胜感激。 Thanks.谢谢。

Assuming that you don't want to return data as one string with the whitespacing (line breaks etc) used above, one of the most common approaches to returning data from a server to be consumed by a client/GUI is to use XML or JSON.假设您不想将数据作为带有上面使用的空格(换行符等)的字符串返回,从服务器返回数据以供客户端/GUI 使用的最常见方法之一是使用 XML 或 JSON . JSON's probably sufficient, and Python has a built-in module for converting dictionaries and lists to JSON . JSON 可能就足够了,并且 Python 具有用于将字典和列表转换为 JSON 的内置模块 If you're working with Pandas, it also has built-in JSON decoders .如果您使用的是 Pandas,它还具有内置的 JSON 解码器

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM