tessl install tessl/pypi-tabulate@0.9.0Pretty-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%
Build a Python tool that formats employee data from different sources into readable tables with appropriate column headers.
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:
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"}format_csv_data(data) that formats CSV-like data (Format 1) into a table using the first row as column headersformat_dict_data(data) that formats dictionary records (Format 2) into a table with headers extracted from the dictionary keysformat_legacy_data(data, column_mapping) that formats legacy data (Format 3) into a table using the provided mapping to display readable column names@generates
format_csv_data correctly uses the first row as headers and displays remaining rows as data @testformat_dict_data correctly extracts headers from dictionary keys @testformat_legacy_data correctly applies the column mapping to display readable headers @testdef 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
"""
passProvides table formatting functionality.