CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-tabulate

Pretty-print tabular data in Python with extensive formatting options and output format support.

Overall
score

69%

Overview
Eval results
Files

task.mdevals/scenario-9/

Multi-Format Report Generator

Build a report generation system that produces sales data reports in multiple output formats.

Requirements

Your system should accept sales data containing product names, quantities sold, revenue, and profit margins. It should generate formatted reports in different styles depending on the target audience and platform.

Core Functionality

Implement a ReportGenerator class with the following capabilities:

  1. Format Selection: Generate reports in 4 different output formats:

    • 'github' - GitHub Flavored Markdown tables
    • 'psql' - PostgreSQL-style console output
    • 'html' - HTML table markup
    • 'latex' - LaTeX tabular format
  2. Data Input: Accept sales data as a list of dictionaries where each dictionary has keys: product (string), quantity (int), revenue (float), margin (float)

  3. Column Headers: Extract column headers from the dictionary keys

  4. Return Value: The generate_report(data, format_type) method must return a formatted string representation of the table

Test Cases

  • Given sales data with 3 products, generating a report with format 'github' produces a GitHub-flavored markdown table with pipes and headers @test
  • Given the same data, generating a report with format 'psql' produces PostgreSQL-style console output @test
  • Given the same data, generating a report with format 'html' produces HTML table markup @test
  • Given the same data, generating a report with format 'latex' produces LaTeX tabular environment code @test

Implementation

@generates

API

class ReportGenerator:
    """
    Generates formatted reports from sales data in multiple output formats.
    """

    def generate_report(self, data, format_type):
        """
        Generate a formatted report from sales data.

        Args:
            data: List of dictionaries containing product sales information.
                  Each dict has keys: product, quantity, revenue, margin
            format_type: String indicating desired format
                        ('markdown', 'psql', 'html', 'latex')

        Returns:
            String containing the formatted report
        """
        pass

Dependencies { .dependencies }

tabulate { .dependency }

Provides table formatting support.

Install with Tessl CLI

npx tessl i tessl/pypi-tabulate

tile.json