Pretty-print tabular data in Python with extensive formatting options and output format support.
Overall
score
69%
Build a Python program that generates formatted reports from datasets containing incomplete data. The program should handle missing values appropriately when creating tables.
Your program should read data from CSV files and generate formatted table reports that:
The program will read CSV files where some cells may be empty (representing missing data). For example:
Name,Age,Department,Salary
Alice,30,Engineering,75000
Bob,,Marketing,
Charlie,45,Engineering,85000
Dana,28,,62000The program should output a formatted table that:
Input CSV (employees_basic.csv):
Name,Score
Alice,95
Bob,
Charlie,87Expected behavior:
@test
Input CSV (employees_detailed.csv):
Name,Age,Salary
Alice,30,75000
Bob,,50000
Charlie,35,Expected behavior:
@test
@generates
def generate_report(csv_file_path: str, missing_placeholder: str = "N/A") -> str:
"""
Generate a formatted table report from a CSV file with missing value handling.
Args:
csv_file_path: Path to the CSV file to process
missing_placeholder: Placeholder text for missing values (default: "N/A")
Returns:
A formatted table as a string
"""
pass
def generate_report_with_column_placeholders(
csv_file_path: str,
column_placeholders: dict
) -> str:
"""
Generate a formatted table report with column-specific missing value placeholders.
Args:
csv_file_path: Path to the CSV file to process
column_placeholders: Dictionary mapping column names to their placeholder text
e.g., {"Age": "Unknown", "Salary": "Confidential"}
Returns:
A formatted table as a string
"""
passProvides table formatting functionality with support for handling missing values.
Install with Tessl CLI
npx tessl i tessl/pypi-tabulatedocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10