CtrlK
CommunityDocumentationLog inGet started
Tessl Logo

tessl/pypi-tabulate

tessl install tessl/pypi-tabulate@0.9.0

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

Agent Success

Agent success rate when using this tile

69%

Improvement

Agent success rate improvement when using this tile compared to baseline

0.9x

Baseline

Agent success rate without this tile

77%

task.mdevals/scenario-3/

Employee Data Formatter

Build a Python tool that formats employee data from different sources into readable tables with appropriate column headers.

Requirements

You need to implement a module that processes employee data in various formats and outputs formatted tables. The module should handle three different input scenarios:

  1. CSV-like raw data: Data provided as nested lists where the first row contains column names
  2. Dictionary records: Employee records provided as a list of dictionaries with consistent keys
  3. Legacy system data: Data from an old system where column identifiers need to be mapped to human-readable names

Input Formats

Format 1: CSV-like data

[
    ["emp_id", "name", "dept", "salary"],
    [101, "Alice Smith", "Engineering", 95000],
    [102, "Bob Jones", "Marketing", 78000],
    [103, "Carol Lee", "Engineering", 102000]
]

Format 2: Dictionary records

[
    {"employee_id": 101, "full_name": "Alice Smith", "department": "Engineering", "annual_salary": 95000},
    {"employee_id": 102, "full_name": "Bob Jones", "department": "Marketing", "annual_salary": 78000},
    {"employee_id": 103, "full_name": "Carol Lee", "department": "Engineering", "annual_salary": 102000}
]

Format 3: Legacy system data with mapping

data = [
    {"eid": 101, "nm": "Alice Smith", "dp": "Engineering", "sal": 95000},
    {"eid": 102, "nm": "Bob Jones", "dp": "Marketing", "sal": 78000},
    {"eid": 103, "nm": "Carol Lee", "dp": "Engineering", "sal": 102000}
]
mapping = {"eid": "Employee ID", "nm": "Name", "dp": "Department", "sal": "Salary"}

Expected Behavior

  1. Create a function format_csv_data(data) that formats CSV-like data (Format 1) into a table using the first row as column headers
  2. Create a function format_dict_data(data) that formats dictionary records (Format 2) into a table with headers extracted from the dictionary keys
  3. Create a function format_legacy_data(data, column_mapping) that formats legacy data (Format 3) into a table using the provided mapping to display readable column names
  4. All functions should return formatted table strings in a readable format

Implementation

@generates

Tests

  • format_csv_data correctly uses the first row as headers and displays remaining rows as data @test
  • format_dict_data correctly extracts headers from dictionary keys @test
  • format_legacy_data correctly applies the column mapping to display readable headers @test
  • All formatting functions produce tables with properly aligned columns @test

API

def format_csv_data(data: list) -> str:
    """
    Format CSV-like data where the first row contains headers.

    Args:
        data: A list of lists where the first sublist contains column names

    Returns:
        A formatted table string
    """
    pass

def format_dict_data(data: list) -> str:
    """
    Format a list of dictionaries into a table.

    Args:
        data: A list of dictionaries with consistent keys

    Returns:
        A formatted table string with headers extracted from dictionary keys
    """
    pass

def format_legacy_data(data: list, column_mapping: dict) -> str:
    """
    Format legacy data with custom column name mapping.

    Args:
        data: A list of dictionaries with abbreviated keys
        column_mapping: A dictionary mapping old keys to readable column names

    Returns:
        A formatted table string with mapped column headers
    """
    pass

Dependencies { .dependencies }

tabulate { .dependency }

Provides table formatting functionality.

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/tabulate@0.9.x
tile.json